home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / IEditor / Generators / C_lib / funcs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-17  |  66.7 KB  |  2,172 lines

  1. /*
  2. **
  3. **    C_IE_Mod.generator - Copyright © 1996 Simone Tellini
  4. **                         All Rights Reserved
  5. **
  6. **    $VER: C_IE_Mod.generator 37.1 (29.4.96)
  7. **
  8. **    This is a cut-down version of the standard C generator.
  9. **    I use it to generate the GUI for IE's external module.
  10. **
  11. */
  12.  
  13. /// Includes
  14. #define INTUI_V36_NAMES_ONLY
  15.  
  16. #include <exec/nodes.h>                 // exec
  17. #include <exec/lists.h>
  18. #include <exec/memory.h>
  19. #include <exec/types.h>
  20. #include <dos/dos.h>                    // dos
  21. #include <dos/dostags.h>
  22. #include <intuition/intuition.h>        // intuition
  23. #include <intuition/gadgetclass.h>
  24. #include <graphics/text.h>              // graphics
  25. #include <libraries/gadtools.h>         // libraries
  26. #include <libraries/reqtools.h>
  27. #include <clib/exec_protos.h>           // protos
  28. #include <clib/dos_protos.h>
  29. #include <clib/intuition_protos.h>
  30. #include <clib/reqtools_protos.h>
  31. #include <pragmas/exec_pragmas.h>       // pragmas
  32. #include <pragmas/dos_pragmas.h>
  33. #include <pragmas/intuition_pragmas.h>
  34. #include <pragmas/graphics_pragmas.h>
  35. #include <pragmas/gadtools_pragmas.h>
  36. #include <pragmas/reqtools_pragmas.h>
  37.  
  38. #include <stdarg.h>
  39. #include <string.h>
  40. #include <stdio.h>
  41. #include <stdlib.h>
  42. #include <ctype.h>
  43.  
  44. #include "DEV_IE:Generators/defs.h"
  45. #include "DEV_IE:Include/IEditor.h"
  46. #include "Config.h"
  47. ///
  48. /// Prototypes
  49. static void WriteSetupScr( struct GenFiles *, struct IE_Data * );
  50. static void WriteOpenWnd( struct GenFiles *, struct IE_Data * );
  51. static void WriteRender( struct GenFiles *, struct IE_Data * );
  52. static void WriteIDCMPHandler( struct GenFiles *, struct IE_Data * );
  53. static void WriteKeyHandler( struct GenFiles *, struct IE_Data * );
  54. static void WriteClickedPtrs( struct GenFiles *, struct IE_Data * );
  55.  
  56. static BOOL AskFile( UBYTE *, struct IE_Data * );
  57. static void WriteList( struct GenFiles *, struct MinList *, UBYTE *, UWORD, struct IE_Data *IE );
  58.  
  59. static void WriteNewGadgets( struct GenFiles *, struct IE_Data * );
  60. static void WriteGadgetTags( struct GenFiles *, struct IE_Data * );
  61. static void WriteITexts( struct GenFiles *, struct IE_Data * );
  62. static void WriteImgStruct( struct GenFiles *, struct IE_Data * );
  63. static void WriteImageStruct( struct GenFiles *, struct IE_Data * );
  64. static void WriteWindowTags( struct GenFiles *, struct IE_Data *, struct WindowInfo * );
  65. ///
  66. /// Data
  67. static ULONG CheckedTag[] = { GTCB_Checked, 0, TAG_END };
  68.  
  69. static UWORD stringjusts[] = {
  70.     GACT_STRINGLEFT, GACT_STRINGRIGHT, GACT_STRINGCENTER
  71. };
  72.  
  73. static ULONG gadget_flags[] = { 1, 2, 4, 8, 16, 0 };
  74.  
  75. static ULONG idcmps[] = {
  76.         1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200,
  77.         0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000,
  78.         0x10000, 0x20000, 0x40000, 0x80000, 0x100000,
  79.         0x200000, 0x400000, 0x800000, 0x1000000,
  80.         0x2000000, 0x4000000
  81.       };
  82.  
  83. #define IDCMPS_NUM 27
  84.  
  85. static ULONG wflgs[] = {
  86.         1, 2, 4, 8, 0x10, 0x20, 0, 0x40, 0x80, 0x100, 0x200,
  87.         0x400, 0x800, 0x1000, 0x10000, 0x20000, 0x40000,
  88.         0x200000
  89.       };
  90.  
  91. #define WFLAGS_NUM 18
  92.  
  93. static UBYTE Header[] =
  94.     "/*\n"
  95.     "    C source code created by Interface Editor\n"
  96.     "    Copyright © 1994-1996 by Simone Tellini\n\n"
  97.     "    Generator:  %s\n"
  98.     "    Copy registered to :  %s\n"
  99.     "    Serial Number      : #%ld\n"
  100.     "*/\n\n";
  101.  
  102. static UBYTE *GadKinds[] = {
  103.     "BUTTON_KIND",
  104.     "CHECKBOX_KIND",
  105.     "INTEGER_KIND",
  106.     "LISTVIEW_KIND",
  107.     "MX_KIND",
  108.     "NUMBER_KIND",
  109.     "CYCLE_KIND",
  110.     "PALETTE_KIND",
  111.     "SCROLLER_KIND",
  112.     NULL,
  113.     "SLIDER_KIND",
  114.     "STRING_KIND",
  115.     "TEXT_KIND"
  116. };
  117.  
  118. static UBYTE  *GadFlags[] = {
  119.     "PLACETEXT_LEFT",
  120.     "PLACETEXT_RIGHT",
  121.     "PLACETEXT_ABOVE",
  122.     "PLACETEXT_BELOW",
  123.     "PLACETEXT_IN"
  124. };
  125.  
  126. static UBYTE  *STRINGA_txts[] = {
  127.     NULL,
  128.     "GACT_STRINGRIGHT",
  129.     "GACT_STRINGCENTER"
  130. };
  131.  
  132. static UBYTE  *GTJ_txts[] = {
  133.     NULL,
  134.     "GTJ_RIGHT",
  135.     "GTJ_CENTER"
  136. };
  137.  
  138. static UBYTE  *WndFlags[] = {
  139.     "WFLG_SIZEGADGET",
  140.     "WFLG_DRAGBAR",
  141.     "WFLG_DEPTHGADGET",
  142.     "WFLG_CLOSEGADGET",
  143.     "WFLG_SIZEBRIGHT",
  144.     "WFLG_SIZEBBOTTOM",
  145.     "WFLG_SMART_REFRESH",
  146.     "WFLG_SIMPLE_REFRESH",
  147.     "WFLG_SUPER_BITMAP",
  148.     "WFLG_BACKDROP",
  149.     "WFLG_REPORTMOUSE",
  150.     "WFLG_GIMMEZEROZERO",
  151.     "WFLG_BORDERLESS",
  152.     "WFLG_ACTIVATE",
  153.     "WFLG_RMBTRAP",
  154.     "WFLG_NOCAREREFRESH",
  155.     "WFLG_NW_EXTENDED",
  156.     "WFLG_NEWLOOKMENUS"
  157. };
  158.  
  159. static UBYTE  *WndIDCMP[] = {
  160.     "IDCMP_SIZEVERIFY",
  161.     "IDCMP_NEWSIZE",
  162.     "IDCMP_REFRESHWINDOW",
  163.     "IDCMP_MOUSEBUTTONS",
  164.     "IDCMP_MOUSEMOVE",
  165.     "IDCMP_GADGETDOWN",
  166.     "IDCMP_GADGETUP",
  167.     "IDCMP_REQSET",
  168.     "IDCMP_MENUPICK",
  169.     "IDCMP_CLOSEWINDOW",
  170.     "IDCMP_RAWKEY",
  171.     "IDCMP_REQVERIFY",
  172.     "IDCMP_REQCLEAR",
  173.     "IDCMP_MENUVERIFY",
  174.     "IDCMP_NEWPREFS",
  175.     "IDCMP_DISKINSERTED",
  176.     "IDCMP_DISKREMOVED",
  177.     "IDCMP_WBENCHMESSAGE",
  178.     "IDCMP_ACTIVEWINDOW",
  179.     "IDCMP_INACTIVEWINDOW",
  180.     "IDCMP_DELTAMOVE",
  181.     "IDCMP_VANILLAKEY",
  182.     "IDCMP_INTUITICKS",
  183.     "IDCMP_IDCMPUPDATE",
  184.     "IDCMP_MENUHELP",
  185.     "IDCMP_CHANGEWINDOW",
  186.     "IDCMP_GADGETHELP"
  187. };
  188.  
  189. static UBYTE  *GadIDCMP[] = {
  190.     "BUTTONIDCMP",
  191.     "CHECKBOXIDCMP",
  192.     "INTEGERIDCMP",
  193.     "LISTVIEWIDCMP",
  194.     "MXIDCMP",
  195.     "NUMBERIDCMP",
  196.     "CYCLEIDCMP",
  197.     "PALETTEIDCMP",
  198.     "SCROLLERIDCMP",
  199.     NULL,
  200.     "SLIDERIDCMP",
  201.     "STRINGIDCMP",
  202.     "TEXTIDCMP",
  203.     "IDCMP_GADGETUP|IDCMP_GADGETDOWN"
  204. };
  205.  
  206. static UBYTE   Null[] = "NULL";
  207.  
  208. static UBYTE   GADisabled[]         = "(GA_Disabled), TRUE, ";
  209. static UBYTE   GAImmediate[]        = "(GA_Immediate), TRUE, ";
  210. static UBYTE   GATabCycle[]         = "(GA_TabCycle), FALSE, ";
  211. static UBYTE   GARelVerify[]        = "(GA_RelVerify), TRUE, ";
  212. static UBYTE   STRINGAExitHelp[]    = "(STRINGA_ExitHelp), TRUE, ";
  213. static UBYTE   STRINGAReplaceMode[] = "(STRINGA_ReplaceMode), TRUE, ";
  214. static UBYTE   PGAFreedom[]         = "(PGA_Freedom), LORIENT_VERT, ";
  215. static UBYTE   LAYOUTASpacing[]     = "(LAYOUTA_Spacing), %ld, ";
  216.  
  217. static UBYTE   MenuTmp[] = "\nBOOL %sMenued( void )\n"
  218.             "{\n"
  219.             "\t/*  Routine for menu \"%s\"  */\n"
  220.             "\treturn( TRUE );\n"
  221.             "}\n";
  222.  
  223. static ULONG IDCMPVer[] = { IDCMP_MENUVERIFY, IDCMP_REQVERIFY, IDCMP_SIZEVERIFY };
  224. static UBYTE *IDCMPVerStr[] = {
  225.     "\n\t\tif( class == IDCMP_MENUVERIFY )\n\t\t\trunning = %sMenuVerify( Wnd, Gadgets, IE );\n",
  226.     "\n\t\tif( class == IDCMP_REQVERIFY )\n\t\t\trunning = %sReqVerify( Wnd, Gadgets, IE );\n"
  227.     "\n\t\tif( class == IDCMP_SIZEVERIFY )\n\t\t\trunning = %sSizeVerify( Wnd, Gadgets, IE );\n"
  228. };
  229. static UBYTE *IDCMPVerProto[] = {
  230.     "extern BOOL %sMenuVerify( struct Window *, struct Gadget **, struct IE_Data * );\n"
  231.     "extern BOOL %sReqVerify( struct Window *, struct Gadget **, struct IE_Data * );\n"
  232.     "extern BOOL %sSizeVerify( struct Window *, struct Gadget **, struct IE_Data * );\n"
  233. };
  234. static UBYTE *IDCMPVerTmp[] = {
  235.     "\nBOOL %sMenuVerify( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  236.     "{\n"
  237.     "\t/*  Routine for IDCMP_MENUVERIFY  */\n"
  238.     "\treturn( TRUE );\n"
  239.     "}\n", // ---
  240.     "\nBOOL %sReqVerify( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  241.     "{\n"
  242.     "\t/*  Routine for IDCMP_REQVERIFY  */\n"
  243.     "\treturn( TRUE );\n"
  244.     "}\n", // ---
  245.     "\nBOOL %sSizeVerify( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  246.     "{\n"
  247.     "\t/*  Routine for IDCMP_SIZEVERIFY  */\n"
  248.     "\treturn( TRUE );\n"
  249.     "}\n",
  250. };
  251.  
  252. static UBYTE VanillaTmp[] = "\nBOOL %sVanillaKey( UBYTE, struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  253.                 "{\n"
  254.                 "\t/*  Routine for IDCMP_VANILLAKEY  */\n"
  255.                 "\treturn( TRUE );\n"
  256.                 "}\n";
  257.  
  258. static UBYTE CaseRefresh[] = "\n\t\t\tcase\tIDCMP_REFRESHWINDOW:\n"
  259.                  "\t\t\t\tGT_BeginRefresh( Wnd );\n"
  260.                  "\t\t\t\tGT_EndRefresh( Wnd, TRUE );\n"
  261.                  "\t\t\t\tbreak;\n";
  262.  
  263. static UBYTE CaseRefresh2[] = "\n\t\t\tcase\tIDCMP_REFRESHWINDOW:\n"
  264.                   "\t\t\t\tGT_BeginRefresh( Wnd );\n"
  265.                   "\t\t\t\t%sRender( Wnd, IE );\n"
  266.                   "\t\t\t\tGT_EndRefresh( Wnd, TRUE );\n"
  267.                   "\t\t\t\tbreak;\n";
  268.  
  269. static UBYTE *IDCMPStr[] = {
  270.     NULL,
  271.     "\n\t\t\tcase\tIDCMP_NEWSIZE:\n"
  272.     "\t\t\t\trunning = %sNewSize( Wnd, Gadgets, IE );\n"
  273.     "\t\t\t\tbreak;\n",
  274.  
  275.     CaseRefresh,
  276.  
  277.     "\n\t\t\tcase\tIDCMP_MOUSEBUTTONS:\n"
  278.     "\t\t\t\trunning = %sMouseButtons( Wnd, Gadgets, IE );\n"
  279.     "\t\t\t\tbreak;\n",
  280.  
  281.     "\n\t\t\tcase\tIDCMP_MOUSEMOVE:\n"
  282.     "\t\t\t\trunning = %sMouseMove( Wnd, Gadgets, IE );\n"
  283.     "\t\t\t\tbreak;\n",
  284.  
  285.     "\n\t\t\tcase\tIDCMP_GADGETDOWN:\n"
  286.     "\t\t\t\tfunc = gad->UserData;\n"
  287.     "\t\t\t\trunning = (*func)( Wnd, Gadgets, IE, &Msg );\n"
  288.     "\t\t\t\tbreak;\n",
  289.  
  290.     "\n\t\t\tcase\tIDCMP_GADGETUP:\n"
  291.     "\t\t\t\tfunc = gad->UserData;\n"
  292.     "\t\t\t\trunning = (*func)( Wnd, Gadgets, IE, &Msg );\n"
  293.     "\t\t\t\tbreak;\n",
  294.  
  295.     "\n\t\t\tcase\tIDCMP_REQSET:\n"
  296.     "\t\t\t\trunning = %sReqSet( Wnd, Gadgets, IE );\n"
  297.     "\t\t\t\tbreak;\n",
  298.  
  299.     "\n\t\t\tcase\tIDCMP_MENUPICK:\n"
  300.     "\t\t\t\twhile( %sMsg.Code != MENUNULL ) {\n"
  301.     "\t\t\t\t\tn = ItemAddress( %sMenus, %sMsg.Code );\n"
  302.     "\t\t\t\t\tfunc = (GTMENUITEM_USERDATA( n ));\n"
  303.     "\t\t\t\t\trunning = (*func)( Wnd, Gadgets, IE );\n"
  304.     "\t\t\t\t\t%sMsg.Code = n->NextSelect;\n"
  305.     "\t\t\t\t}\n"
  306.     "\t\t\t\tbreak;\n",
  307.  
  308.     "\n\t\t\tcase\tIDCMP_CLOSEWINDOW:\n"
  309.     "\t\t\t\trunning = %sCloseWindow( Wnd, Gadgets, IE );\n"
  310.     "\t\t\t\tbreak;\n",
  311.  
  312.     "\n\t\t\tcase\tIDCMP_RAWKEY:\n"
  313.     "\t\t\t\trunning = %sRawKey( Wnd, Gadgets, IE );\n"
  314.     "\t\t\t\tbreak;\n",
  315.  
  316.     NULL,
  317.  
  318.     "\n\t\t\tcase\tIDCMP_REQCLEAR:\n"
  319.     "\t\t\t\trunning = %sReqClear( Wnd, Gadgets, IE );\n"
  320.     "\t\t\t\tbreak;\n",
  321.  
  322.     NULL,
  323.  
  324.     "\n\t\t\tcase\tIDCMP_NEWPREFS:\n"
  325.     "\t\t\t\trunning = %sNewPrefs( Wnd, Gadgets, IE );\n"
  326.     "\t\t\t\tbreak;\n",
  327.  
  328.     "\n\t\t\tcase\tIDCMP_DISKINSERTED:\n"
  329.     "\t\t\t\trunning = %sDiskInserted( Wnd, Gadgets, IE );\n"
  330.     "\t\t\t\tbreak;\n",
  331.  
  332.     "\n\t\t\tcase\tIDCMP_DISKREMOVED:\n"
  333.     "\t\t\t\trunning = %sDiskRemoved( Wnd, Gadgets, IE );\n"
  334.     "\t\t\t\tbreak;\n",
  335.  
  336.     "\n\t\t\tcase\tIDCMP_WBENCHMESSAGE:\n"
  337.     "\t\t\t\trunning = %sWBenchMessage( Wnd, Gadgets, IE );\n"
  338.     "\t\t\t\tbreak;\n",
  339.  
  340.     "\n\t\t\tcase\tIDCMP_ACTIVEWINDOW:\n"
  341.     "\t\t\t\trunning = %sActiveWindow( Wnd, Gadgets, IE );\n"
  342.     "\t\t\t\tbreak;\n",
  343.  
  344.     "\n\t\t\tcase\tIDCMP_INACTIVEWINDOW:\n"
  345.     "\t\t\t\trunning = %sInactiveWindow( Wnd, Gadgets, IE );\n"
  346.     "\t\t\t\tbreak;\n",
  347.  
  348.     "\n\t\t\tcase\tIDCMP_DELTAMOVE:\n"
  349.     "\t\t\t\trunning = %sDeltaMove( Wnd, Gadgets, IE );\n"
  350.     "\t\t\t\tbreak;\n",
  351.  
  352.     "\n\t\t\tcase\tIDCMP_VANILLAKEY:\n"
  353.     "\t\t\t\trunning = %sVanillaKey( Code, Wnd, Gadgets, IE );\n"
  354.     "\t\t\t\tbreak;\n",
  355.  
  356.     "\n\t\t\tcase\tIDCMP_INTUITICKS:\n"
  357.     "\t\t\t\trunning = %sIntuiTicks( Wnd, Gadgets, IE );\n"
  358.     "\t\t\t\tbreak;\n",
  359.  
  360.     "\n\t\t\tcase\tIDCMP_IDCMPUPDATE:\n"
  361.     "\t\t\t\trunning = %sIDCMPUpdate( Wnd, Gadgets, IE );\n"
  362.     "\t\t\t\tbreak;\n",
  363.  
  364.     "\n\t\t\tcase\tIDCMP_MENUHELP:\n"
  365.     "\t\t\t\trunning = %sMenuHelp( Wnd, Gadgets, IE );\n"
  366.     "\t\t\t\tbreak;\n",
  367.  
  368.     "\n\t\t\tcase\tIDCMP_CHANGEWINDOW:\n"
  369.     "\t\t\t\trunning = %sChangeWindow( Wnd, Gadgets, IE );\n"
  370.     "\t\t\t\tbreak;\n",
  371.  
  372.     "\n\t\t\tcase\tIDCMP_GADGETHELP:\n"
  373.     "\t\t\t\trunning = %sGadgetHelp( Wnd, Gadgets, IE );\n"
  374.     "\t\t\t\tbreak;\n"
  375. };
  376.  
  377. static UBYTE *IDCMPProto[] = {
  378.     NULL,
  379.     "extern BOOL %sNewSize( struct Window *, struct Gadget **, struct IE_Data * );\n",
  380.     NULL,
  381.     "extern BOOL %sMouseButtons( struct Window *, struct Gadget **, struct IE_Data * );\n",
  382.     "extern BOOL %sMouseMove( struct Window *, struct Gadget **, struct IE_Data * );\n",
  383.     NULL,
  384.     NULL,
  385.     "extern BOOL %sReqSet( struct Window *, struct Gadget **, struct IE_Data * );\n",
  386.     NULL,
  387.     "extern BOOL %sCloseWindow( struct Window *, struct Gadget **, struct IE_Data * );\n",
  388.     "extern BOOL %sRawKey( struct Window *, struct Gadget **, struct IE_Data * );\n",
  389.     NULL,
  390.     "extern BOOL %sReqClear( struct Window *, struct Gadget **, struct IE_Data * );\n",
  391.     NULL,
  392.     "extern BOOL %sNewPrefs( struct Window *, struct Gadget **, struct IE_Data * );\n",
  393.     "extern BOOL %sDiskInserted( struct Window *, struct Gadget **, struct IE_Data * );\n",
  394.     "extern BOOL %sDiskRemoved( struct Window *, struct Gadget **, struct IE_Data * );\n",
  395.     "extern BOOL %sWBenchMessage( struct Window *, struct Gadget **, struct IE_Data * );\n",
  396.     "extern BOOL %sActiveWindow( struct Window *, struct Gadget **, struct IE_Data * );\n",
  397.     "extern BOOL %sInactiveWindow( struct Window *, struct Gadget **, struct IE_Data * );\n",
  398.     "extern BOOL %sDeltaMove( struct Window *, struct Gadget **, struct IE_Data * );\n",
  399.     "extern BOOL %sVanillaKey( UBYTE, struct Window *, struct Gadget **, struct IE_Data * );\n",
  400.     "extern BOOL %sIntuiTicks( struct Window *, struct Gadget **, struct IE_Data * );\n",
  401.     "extern BOOL %sIDCMPUpdate( struct Window *, struct Gadget **, struct IE_Data * );\n",
  402.     "extern BOOL %sMenuHelp( struct Window *, struct Gadget **, struct IE_Data * );\n",
  403.     "extern BOOL %sChangeWindow( struct Window *, struct Gadget **, struct IE_Data * );\n",
  404.     "extern BOOL %sGadgetHelp( struct Window *, struct Gadget **, struct IE_Data * );\n"
  405. };
  406.  
  407. static UBYTE *IDCMPTmp[] = {
  408.     NULL,
  409.     "\nBOOL %sNewSize( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  410.     "{\n"
  411.     "\t/*  Routine for IDCMP_NEWSIZE  */\n"
  412.     "\treturn( TRUE );\n"
  413.     "}\n",
  414.     NULL,
  415.     "\nBOOL %sMouseButtons( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  416.     "{\n"
  417.     "\t/*  Routine for IDCMP_MOUSEBUTTONS  */\n"
  418.     "\treturn( TRUE );\n"
  419.     "}\n",
  420.  
  421.     "\nBOOL %sMouseMove( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  422.     "{\n"
  423.     "\t/*  Routine for IDCMP_MOUSEMOVE  */\n"
  424.     "\treturn( TRUE );\n"
  425.     "}\n",
  426.  
  427.     NULL,
  428.     NULL,
  429.     "\nBOOL %sReqSet( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  430.     "{\n"
  431.     "\t/*  Routine for IDCMP_REQSET  */\n"
  432.     "\treturn( TRUE );\n"
  433.     "}\n",
  434.     NULL,
  435.     "\nBOOL %sCloseWindow( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  436.     "{\n"
  437.     "\t/*  Routine for IDCMP_CLOSEWINDOW  */\n"
  438.     "\t/*  Return FALSE to quit, I suppose... ;)  */\n"
  439.     "\treturn( FALSE );\n"
  440.     "}\n",
  441.  
  442.     "\nBOOL %sRawKey( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  443.     "{\n"
  444.     "\t/*  Routine for IDCMP_RAWKEY  */\n"
  445.     "\treturn( TRUE );\n"
  446.     "}\n",
  447.  
  448.     NULL,
  449.     "\nBOOL %sReqClear( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  450.     "{\n"
  451.     "\t/*  Routine for IDCMP_REQCLEAR  */\n"
  452.     "\treturn( TRUE );\n"
  453.     "}\n",
  454.     NULL,
  455.     "\nBOOL %sNewPrefs( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  456.     "{\n"
  457.     "\t/*  Routine for IDCMP_NEWPREFS  */\n"
  458.     "\treturn( TRUE );\n"
  459.     "}\n",
  460.  
  461.     "\nBOOL %sDiskInserted( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  462.     "{\n"
  463.     "\t/*  Routine for IDCMP_DISKINSERTED  */\n"
  464.     "\treturn( TRUE );\n"
  465.     "}\n",
  466.  
  467.     "\nBOOL %sDiskRemoved( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  468.     "{\n"
  469.     "\t/*  Routine for IDCMP_DISKREMOVED  */\n"
  470.     "\treturn( TRUE );\n"
  471.     "}\n",
  472.  
  473.     "\nBOOL %sWBenchMessage( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  474.     "{\n"
  475.     "\t/*  Routine for IDCMP_WBENCHMESSAGE  */\n"
  476.     "\treturn( TRUE );\n"
  477.     "}\n",
  478.  
  479.     "\nBOOL %sActiveWindow( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  480.     "{\n"
  481.     "\t/*  Routine for IDCMP_ACTIVEWINDOW  */\n"
  482.     "\treturn( TRUE );\n"
  483.     "}\n",
  484.  
  485.     "\nBOOL %sInactiveWindow( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  486.     "{\n"
  487.     "\t/*  Routine for IDCMP_INACTIVEWINDOW  */\n"
  488.     "\treturn( TRUE );\n"
  489.     "}\n",
  490.  
  491.     "\nBOOL %sDeltaMove( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  492.     "{\n"
  493.     "\t/*  Routine for IDCMP_DELTAMOVE  */\n"
  494.     "\treturn( TRUE );\n"
  495.     "}\n",
  496.  
  497.     "\nBOOL %sVanillaKey( UBYTE Code, struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  498.     "{\n"
  499.     "\t/*  Routine for IDCMP_VANILLAKEY  */\n"
  500.     "\treturn( TRUE );\n"
  501.     "}\n",
  502.  
  503.     "\nBOOL %sIntuiTicks( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  504.     "{\n"
  505.     "\t/*  Routine for IDCMP_INTUITICKS  */\n"
  506.     "\treturn( TRUE );\n"
  507.     "}\n",
  508.  
  509.     "\nBOOL %sIDCMPUpdate( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  510.     "{\n"
  511.     "\t/*  Routine for IDCMP_IDCMPUPDATE  */\n"
  512.     "\treturn( TRUE );\n"
  513.     "}\n",
  514.  
  515.     "\nBOOL %sMenuHelp( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  516.     "{\n"
  517.     "\t/*  Routine for IDCMP_MENUHELP  */\n"
  518.     "\treturn( TRUE );\n"
  519.     "}\n",
  520.  
  521.     "\nBOOL %sChangeWindow( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  522.     "{\n"
  523.     "\t/*  Routine for IDCMP_CHANGEWINDOW  */\n"
  524.     "\treturn( TRUE );\n"
  525.     "}\n",
  526.  
  527.     "\nBOOL %sGadgetHelp( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  528.     "{\n"
  529.     "\t/*  Routine for IDCMP_GADGETHELP  */\n"
  530.     "\treturn( TRUE );\n"
  531.     "}\n"
  532. };
  533. ///
  534.  
  535.  
  536. // Misc
  537. /// AskFile
  538. BOOL AskFile( UBYTE *File, struct IE_Data *IE )
  539. {
  540.     BOOL    ret = TRUE;
  541.     BPTR    lock;
  542.  
  543.     if( lock = Lock( File, ACCESS_READ )) {
  544.  
  545.     UnLock( lock );
  546.  
  547.     ULONG   tags[] = { RT_ReqPos, REQPOS_CENTERSCR, RT_Underscore, '_',
  548.                RT_Screen, IE->ScreenData->Screen, TAG_DONE };
  549.  
  550.     ret = rtEZRequest( "%s alreay exists.\n"
  551.                "Overwrite?",
  552.                "_Yes|_No",
  553.                NULL, (struct TagItem *)tags,
  554.                FilePart( File )
  555.              );
  556.     }
  557.  
  558.     return( ret );
  559. }
  560. ///
  561. /// WriteList
  562. void WriteList( struct GenFiles *Files, struct MinList *List, UBYTE *Label, UWORD Num, struct IE_Data *IE )
  563. {
  564.     struct GadgetScelta *gs;
  565.     UWORD                cnt;
  566.  
  567.     if( Num ) {
  568.  
  569.     FPrintf( Files->XDef, "extern struct MinList %sList;\n", Label );
  570.  
  571.     FPrintf( Files->Std, "\nstruct Node %sNodes[] = {\n\t", Label );
  572.  
  573.     gs = List->mlh_Head;
  574.  
  575.     if( Num == 1 ) {
  576.         FPrintf( Files->Std, "(struct Node *)&%sList.mlh_Tail, (struct Node *)&%sList.mlh_Head, 0, 0, ",
  577.              Label, Label );
  578.  
  579.         FPrintf( Files->Std, "\"%s\"", gs->gs_Testo );
  580.  
  581.         FPuts( Files->Std, " };\n" );
  582.     } else {
  583.  
  584.         FPrintf( Files->Std, "&%sNodes[1], (struct Node *)&%sList.mlh_Head, 0, 0, ",
  585.              Label, Label );
  586.  
  587.         FPrintf( Files->Std, "\"%s\"", gs->gs_Testo );
  588.  
  589.         FPuts( Files->Std, ",\n" );
  590.  
  591.         for( cnt = 1; cnt < Num - 1; cnt++ ) {
  592.  
  593.         gs = gs->gs_Node.ln_Succ;
  594.  
  595.         FPrintf( Files->Std, "\t&%sNodes[%ld], &%sNodes[%ld], 0, 0, ",
  596.              Label, cnt + 1, Label, cnt - 1 );
  597.  
  598.         FPrintf( Files->Std, "\"%s\"", gs->gs_Testo );
  599.  
  600.         FPuts( Files->Std, ",\n" );
  601.         }
  602.  
  603.         gs = gs->gs_Node.ln_Succ;
  604.         FPrintf( Files->Std, "\t(struct Node *)&%sList.mlh_Tail, &%sNodes[%ld], 0, 0, ",
  605.              Label, Label, Num - 2 );
  606.  
  607.         FPrintf( Files->Std, "\"%s\"", gs->gs_Testo );
  608.  
  609.         FPuts( Files->Std, " };\n" );
  610.     }
  611.  
  612.     FPrintf( Files->Std, "\nstruct MinList %sList = {\n"
  613.                  "\t(struct MinNode *)&%sNodes[0], (struct MinNode *)NULL, (struct MinNode *)&%sNodes[%ld] };\n",
  614.          Label, Label, Label, Num - 1 );
  615.     }
  616. }
  617. ///
  618.  
  619. // Code
  620. /// WriteSetupScr
  621. void WriteSetupScr( struct GenFiles *Files, struct IE_Data *IE )
  622. {
  623.     if( IE->SrcFlags & FONTSENSITIVE ) {
  624.  
  625.     FPuts( Files->XDef, "extern UWORD ScaleX( UWORD, UWORD );\n"
  626.                 "extern UWORD ScaleY( UWORD, UWORD );\n" );
  627.  
  628.     FPrintf( Files->Std, "\nUWORD ScaleX( UWORD FontX, UWORD value )\n"
  629.                  "{\n"
  630.                  "\treturn(( UWORD )((( FontX * value ) + %ld ) / %ld ));\n"
  631.                  "}\n"
  632.                  "\n"
  633.                  "UWORD ScaleY( UWORD FontY, UWORD value )\n"
  634.                  "{\n"
  635.                  "\treturn(( UWORD )((( FontY * value ) + %ld ) / %ld ));\n"
  636.                  "}\n",
  637.          IE->ScreenData->Screen->RastPort.Font->tf_XSize >> 1,
  638.          IE->ScreenData->Screen->RastPort.Font->tf_XSize,
  639.          IE->ScreenData->Screen->RastPort.Font->tf_YSize >> 1,
  640.          IE->ScreenData->Screen->RastPort.Font->tf_YSize );
  641.     }
  642.  
  643.     FPuts( Files->Std, "\nvoid CloseWnd( struct Window **Wnd, struct Gadget **GList )\n"
  644.                "{\n"
  645.                "\tif( *Wnd ) {\n"
  646.                "\t\tCloseWindow( *Wnd );\n"
  647.                "\t\t*Wnd = NULL;\n"
  648.                "\t}\n"
  649.                "\tif( GList ) {\n"
  650.                "\t\tFreeGadgets( *GList );\n"
  651.                "\t\t*GList = NULL;\n"
  652.                "\t}\n"
  653.                "}\n" );
  654. }
  655. ///
  656. /// WriteOpenWnd
  657. void WriteOpenWnd( struct GenFiles *Files, struct IE_Data *IE )
  658. {
  659.     struct WindowInfo  *wnd;
  660.     UWORD               cnt = 0;
  661.  
  662.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  663.  
  664.     FPrintf( Files->XDef, "extern LONG Open%sWindow( struct Window **, struct Gadget **, struct Gadget **, struct IE_Data * );\n",
  665.          wnd->wi_Label );
  666.  
  667.     FPrintf( Files->Std, "\nLONG Open%sWindow( struct Window **Wnd, struct Gadget **GList, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  668.                  "{\n"
  669.                  "\tLONG\t\tret_code = NULL;\n",
  670.          wnd->wi_Label );
  671.  
  672.     if( IE->SrcFlags & FONTSENSITIVE ) {
  673.         FPrintf( Files->Std, "\tUWORD\t\tFontX, FontY;\n"
  674.                  "\tstruct TextAttr\t*Font;\n\n"
  675.                  "\tFont = IE->ScreenData->Screen->Font;\n"
  676.                  "\tFontY = IE->ScreenData->Screen->RastPort.Font->tf_YSize;\n"
  677.                  "\tFontX = IE->ScreenData->Screen->RastPort.Font->tf_XSize;\n"
  678.                  "\n"
  679.                  "\tif((( ScaleX( FontX, %ld ) + IE->ScreenData->Screen->WBorRight + IE->ScreenData->XOffset ) > IE->ScreenData->Screen->Width ) ||\n"
  680.                  "\t\t(( ScaleY( FontY, %ld ) + IE->ScreenData->Screen->WBorBottom + IE->ScreenData->YOffset ) > IE->ScreenData->Screen->Height )) {\n"
  681.                  "\t\t\tFont = &topaz8_065;\n"
  682.                  "\t\t\tFontX = FontY = 8;\n"
  683.                  "\t\t}\n",
  684.              wnd->wi_Width - ( IE->ScreenData->XOffset + IE->ScreenData->Screen->WBorRight  ),
  685.              wnd->wi_Height - ( IE->ScreenData->YOffset + IE->ScreenData->Screen->WBorBottom ));
  686.     }
  687.  
  688.     if( wnd->wi_NumGads ) {
  689.  
  690.         FPrintf( Files->Std, "\n\tstruct Gadget\t\t*g;\n"
  691.                  "\tUWORD\t\t\tlc, tc;\n"
  692.                  "\tstruct NewGadget\tng;\n"
  693.                  "\n"
  694.                  "\tif(!( g = CreateContext( GList )))\n"
  695.                  "\t\treturn( 1L );\n"
  696.                  "\n"
  697.                  "\tfor( lc = 0, tc = 0; lc < %s_CNT; lc++ ) {\n\n"
  698.                  "\t\tCopyMem(( char * )&%sNGad[ lc ], ( char * )&ng, ( long )sizeof( struct NewGadget ));\n"
  699.                  "\t\tng.ng_VisualInfo = IE->ScreenData->Visual;\n",
  700.              wnd->wi_Label, wnd->wi_Label );
  701.  
  702.         if( IE->SrcFlags & FONTSENSITIVE )
  703.         FPuts( Files->Std, "\t\tng.ng_TextAttr = Font;\n"
  704.                    "\t\tng.ng_LeftEdge = IE->ScreenData->XOffset + ScaleX( FontX, ng.ng_LeftEdge );\n"
  705.                    "\t\tng.ng_TopEdge  = IE->ScreenData->YOffset + ScaleY( FontY, ng.ng_TopEdge  );\n"
  706.                    "\t\tng.ng_Width    = ScaleX( FontX, ng.ng_Width  );\n"
  707.                    "\t\tng.ng_Height   = ScaleY( FontY, ng.ng_Height );\n" );
  708.         else
  709.         FPuts( Files->Std, "\t\tng.ng_TopEdge  += IE->ScreenData->YOffset;\n"
  710.                    "\t\tng.ng_LeftEdge += IE->ScreenData->XOffset;\n" );
  711.  
  712.         FPrintf( Files->Std, "\t\tGadgets[ lc ] = g = CreateGadgetA((ULONG)%sGTypes[ lc ], g, &ng, (struct TagItem *)&%sGTags[ tc ] );\n\n"
  713.                  "\t\twhile( %sGTags[ tc ] ) tc += 2;\n"
  714.                  "\t\ttc++;\n\n"
  715.                  "\t\tif( !g )\n"
  716.                  "\t\t\treturn( 2L );\n"
  717.                  "\t}\n\n",
  718.              wnd->wi_Label, wnd->wi_Label, wnd->wi_Label );
  719.  
  720.     }
  721.  
  722.     WriteWindowTags( Files, IE, wnd );
  723.  
  724.     if( IE->SrcFlags & FONTSENSITIVE )
  725.         FPuts( Files->Std, "\n\tWTags[ WT_LEFT ].ti_Data = (IE->ScreenData->Screen->Width  - WTags[ WT_WIDTH  ].ti_Data) >> 1;\n"
  726.                    "\tWTags[ WT_TOP  ].ti_Data = (IE->ScreenData->Screen->Height - WTags[ WT_HEIGHT ].ti_Data) >> 1;\n" );
  727.  
  728.     FPuts( Files->Std, "\n\tif(!( *Wnd = OpenWindowTagList( NULL, &WTags[0] )))\n"
  729.                "\t\treturn( 4L );\n"
  730.                "\n\tGT_RefreshWindow( *Wnd, NULL );\n" );
  731.  
  732.     if( wnd->wi_NumBoxes + wnd->wi_NumImages + wnd->wi_NumTexts )
  733.         FPrintf( Files->Std, "\n\t%sRender( *Wnd, IE );\n", wnd->wi_Label );
  734.  
  735.     FPrintf( Files->Std, "\treturn( 0L );\n"
  736.                  "}\n",
  737.          wnd->wi_Label );
  738.     }
  739. }
  740. ///
  741. /// WriteRender
  742. void WriteRender( struct GenFiles *Files, struct IE_Data *IE )
  743. {
  744.     struct WindowInfo      *wnd;
  745.     struct BevelBoxNode    *box;
  746.     WORD                    x, y;
  747.  
  748.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  749.     if( wnd->wi_NumBoxes + wnd->wi_NumImages + wnd->wi_NumTexts ) {
  750.  
  751.         FPrintf( Files->XDef, "extern void %sRender( struct Window *, struct IE_Data * );\n", wnd->wi_Label );
  752.  
  753.         FPrintf( Files->Std, "\nvoid %sRender( struct Window *Wnd, struct IE_Data *IE )\n{\n", wnd->wi_Label );
  754.  
  755.         if( IE->SrcFlags & FONTSENSITIVE ) {
  756.  
  757.         if( wnd->wi_NumImages )
  758.             FPuts( Files->Std, "\tstruct Image\t\tim;\n"
  759.                        "\tstruct Image\t\t*imp;\n" );
  760.  
  761.         if( wnd->wi_NumTexts )
  762.             FPuts( Files->Std, "\tstruct IntuiText\tit;\n" );
  763.  
  764.         if(( wnd->wi_NumImages ) || ( wnd->wi_NumTexts ))
  765.             FPuts( Files->Std, "\tUWORD\t\t\tc;\n" );
  766.         }
  767.  
  768.         for( box = wnd->wi_Boxes.mlh_Head; box->bb_Next; box = box->bb_Next ) {
  769.         x = box->bb_Left - IE->ScreenData->XOffset;
  770.         y = box->bb_Top  - IE->ScreenData->YOffset;
  771.  
  772.         if( IE->SrcFlags & FONTSENSITIVE )
  773.             FPrintf( Files->Std, "\n\tDrawBevelBox( Wnd->RPort, ScaleX( FontX, %ld ) + IE->ScreenData->XOffset, ScaleY( FontY, %ld ) + IE->ScreenData->YOffset, ScaleX( %ld ), ScaleY( %ld ),\n"
  774.                      "\t\tGT_VisualInfo, IE->ScreenData->Visual,",
  775.                  x, y, box->bb_Width, box->bb_Height );
  776.         else
  777.             FPrintf( Files->Std, "\n\tDrawBevelBox( Wnd->RPort, %ld + IE->ScreenData->XOffset, %ld + IE->ScreenData->YOffset, %ld, %ld,\n"
  778.                      "\t\tGT_VisualInfo, IE->ScreenData->Visual,",
  779.                  x, y, box->bb_Width, box->bb_Height );
  780.  
  781.         if( box->bb_Recessed )
  782.             FPuts( Files->Std, " GTBB_Recessed, TRUE," );
  783.  
  784.         if( box->bb_FrameType != 1 )
  785.             VFPrintf( Files->Std, " GTBB_FrameType, %ld,", &box->bb_FrameType );
  786.  
  787.         FPuts( Files->Std, " TAG_DONE );\n" );
  788.         }
  789.  
  790.         if( wnd->wi_NumImages ) {
  791.         if( IE->SrcFlags & FONTSENSITIVE ) {
  792.             FPrintf( Files->Std, "\n\timp = &%s_0Image;\n"
  793.                      "\tfor( c = 0; c < %ld; c++ ) {\n"
  794.                      "\t\tCopyMem(( char * )imp, ( char * )&im, ( long )sizeof( struct Image ));\n"
  795.                      "\t\timp = imp->NextImage;\n"
  796.                      "\t\tim.NextImage = NULL;\n"
  797.                      "\t\tim.LeftEdge  = IE->ScreenData->XOffset + ScaleX( im.LeftEdge );\n"
  798.                      "\t\tim.TopEdge   = IE->ScreenData->YOffset + ScaleY( im.TopEdge  );\n"
  799.                      "\t\tDrawImage( Wnd->RPort, &im, 0, 0 );\n"
  800.                      "\t}\n",
  801.                  wnd->wi_Label, wnd->wi_NumImages );
  802.         } else {
  803.             FPrintf( Files->Std, "\n\tDrawImage( Wnd->RPort, &%s_0Image, XOffset, YOffset );\n",
  804.                  wnd->wi_Label );
  805.         }
  806.         }
  807.  
  808.         if( wnd->wi_NumTexts ) {
  809.         if( IE->SrcFlags & FONTSENSITIVE ) {
  810.             FPrintf( Files->Std, "\n\tfor( c = 0; c < %ld; c++ ) {\n"
  811.                      "\t\tCopyMem(( char * )&%sIText[ c ], ( char * )&it, ( long )sizeof( struct IntuiText ));\n"
  812.                      "\t\tit.LeftEdge = IE->ScreenData->XOffset + ScaleX( it.LeftEdge ) - ( IntuiTextLength( &it ) >> 1 );\n"
  813.                      "\t\tit.TopEdge  = IE->ScreenData->YOffset + ScaleY( it.TopEdge  ) - ( Font->ta_YSize >> 1 );\n"
  814.                      "\t\tPrintIText( Wnd->RPort, &it, 0, 0 );\n"
  815.                      "\t}\n",
  816.                  wnd->wi_NumTexts, wnd->wi_Label );
  817.         } else {
  818.             FPrintf( Files->Std, "\n\tPrintIText( Wnd->RPort, %sIText, XOffset, YOffset );\n",
  819.                  wnd->wi_Label );
  820.         }
  821.         }
  822.  
  823.         FPuts( Files->Std, "}\n" );
  824.  
  825.     }
  826.     }
  827. }
  828. ///
  829. /// WriteIDCMPHandler
  830. void WriteIDCMPHandler( struct GenFiles *Files, struct IE_Data *IE )
  831. {
  832.     struct WindowInfo  *wnd;
  833.     UWORD               c;
  834.     ULONG               idcmp;
  835.  
  836.  
  837.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  838.     if( wnd->wi_IDCMP ) {
  839.  
  840.         FPrintf( Files->XDef, "extern LONG Handle%sIDCMP( struct Window *, struct Gadget **, struct IE_Data * );\n", wnd->wi_Label );
  841.  
  842.         FPrintf( Files->Std, "\nLONG Handle%sIDCMP( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )\n"
  843.                  "{\n"
  844.                  "\tstruct IntuiMessage\t*m, Msg;\n",
  845.              wnd->wi_Label );
  846.  
  847.         if( wnd->wi_IDCMP & IDCMP_MENUPICK )
  848.         FPuts( Files->Std, "\tstruct MenuItem\t\t*n;\n" );
  849.  
  850.         FPuts( Files->Std, "\tBOOL\t\t\t(*func)( struct Window *, struct Gadget **, struct IE_Data *, struct IntuiMessage * );\n"
  851.                  "\tBOOL\t\t\trunning = TRUE;\n"
  852.                  "\tint\t\t\tclass;\n"
  853.                  "\tshort\t\t\tcode;\n"
  854.                  "\tstruct Gadget\t*gad;\n"
  855.                  "\n"
  856.                  "\twhile( m = GT_GetIMsg( Wnd->UserPort )) {\n\n"
  857.                  "\t\tclass = m->Class;\n"
  858.                  "\t\tcode  = m->Code;\n"
  859.                  "\t\tgad   = (struct Gadget *)m->IAddress;\n\n"
  860.                  "\t\tCopyMem((char *)m, (char *)&Msg, (long)sizeof( struct IntuiMessage ));\n"  );
  861.  
  862.  
  863.         for( c = 0; c < 3; c++ ) {
  864.         if( wnd->wi_IDCMP & IDCMPVer[ c ]) {
  865.             FPrintf( Files->XDef, IDCMPVerProto[ c ], wnd->wi_Label );
  866.             FPrintf( Files->Std, IDCMPVerStr[ c ], wnd->wi_Label );
  867.             if( IE->C_Prefs & GEN_TEMPLATE )
  868.             FPrintf( Files->Temp, IDCMPVerTmp[ c ], wnd->wi_Label );
  869.         }
  870.         }
  871.  
  872.         FPuts( Files->Std, "\n\t\tGT_ReplyIMsg( m );\n\n"
  873.                    "\t\tswitch( class ) {\n" );
  874.  
  875.         idcmp = wnd->wi_IDCMP;
  876.  
  877.         if(( idcmp & IDCMP_GADGETUP ) && ( idcmp & IDCMP_GADGETDOWN )) {
  878.         idcmp &= ~( IDCMP_GADGETUP | IDCMP_GADGETDOWN );
  879.         FPrintf( Files->Std, "\n\t\t\tcase\tIDCMP_GADGETUP:\n"
  880.                      "\t\t\tcase\tIDCMP_GADGETDOWN:\n"
  881.                      "\t\t\t\tfunc = gad->UserData;\n"
  882.                      "\t\t\t\trunning = (*func)( Wnd, Gadgets, IE, &Msg );\n"
  883.                      "\t\t\t\tbreak;\n",
  884.              wnd->wi_Label );
  885.         }
  886.  
  887.         if(( IE->C_Prefs & KEY_HANDLER ) && ( wnd->wi_NumKeys )) {
  888.  
  889.         FPrintf( Files->Std, "\n\t\t\tcase\tIDCMP_VANILLAKEY:\n"
  890.                      "\t\t\t\trunning = Handle%sKeys( code, Wnd, Gadgets, IE, &Msg );\n"
  891.                      "\t\t\t\tbreak;\n",
  892.              wnd->wi_Label );
  893.  
  894.         if( idcmp & IDCMP_VANILLAKEY ) {
  895.             idcmp &= ~IDCMP_VANILLAKEY;
  896.             FPrintf( Files->XDef, "extern BOOL %sVanillaKey( UBYTE, struct Window *, struct Gadget **, struct IE_Data * );\n", wnd->wi_Label );
  897.             if( IE->C_Prefs & GEN_TEMPLATE )
  898.             FPrintf( Files->Temp, VanillaTmp, wnd->wi_Label );
  899.         }
  900.         }
  901.  
  902.         IDCMPStr[2] = ( wnd->wi_NumBoxes + wnd->wi_NumImages + wnd->wi_NumTexts ) ? CaseRefresh2 : CaseRefresh;
  903.  
  904.         for( c = 0; c < IDCMPS_NUM; c++ ) {
  905.         if( idcmp & idcmps[ c ]) {
  906.             if( IDCMPStr[ c ]) {
  907.  
  908.             FPrintf( Files->Std, IDCMPStr[ c ],
  909.                  wnd->wi_Label, wnd->wi_Label,
  910.                  wnd->wi_Label, wnd->wi_Label );
  911.  
  912.             if( IDCMPProto[ c ])
  913.                 FPrintf( Files->XDef, IDCMPProto[ c ], wnd->wi_Label );
  914.  
  915.             if(( IE->C_Prefs & GEN_TEMPLATE ) && ( IDCMPTmp[ c ]))
  916.                 FPrintf( Files->Temp, IDCMPTmp[ c ], wnd->wi_Label );
  917.             }
  918.         }
  919.         }
  920.  
  921.         FPuts( Files->Std, "\n\t\t}\n\t}\n\treturn( running );\n}\n" );
  922.     }
  923.     }
  924. }
  925. ///
  926. /// WriteKeyHandler
  927. void WriteKeyHandler( struct GenFiles *Files, struct IE_Data *IE )
  928. {
  929.     struct WindowInfo  *wnd;
  930.     struct GadgetInfo  *gad;
  931.     UBYTE               ch;
  932.  
  933.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  934.     if( wnd->wi_NumKeys ) {
  935.  
  936.         FPrintf( Files->XDef, "extern BOOL Handle%sKeys( UBYTE, struct Window *, struct Gadget **, struct IE_Data *, struct IntuiMessage * );\n", wnd->wi_Label );
  937.  
  938.         FPrintf( Files->Std, "\nBOOL Handle%sKeys( UBYTE Code, struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )\n"
  939.                  "{\n"
  940.                  "\tBOOL running = TRUE;\n\n",
  941.              wnd->wi_Label );
  942.  
  943.         if( IE->C_Prefs & TO_LOWER )
  944.         FPuts( Files->Std, "\tswitch( tolower( Code )) {\n" );
  945.         else
  946.         FPuts( Files->Std, "\tswitch( Code ) {\n" );
  947.  
  948.         for( gad = wnd->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  949.         if(( gad->g_Tags & 1 ) && ( gad->g_Key )) {
  950.  
  951.             ch = ( IE->C_Prefs & TO_LOWER ) ? tolower( gad->g_Key ) : gad->g_Key;
  952.  
  953.             if(( gad->g_Kind == STRING_KIND ) || ( gad->g_Kind == INTEGER_KIND )) {
  954.             FPrintf( Files->Std, "\n\t\tcase\t'%lc':\n"
  955.                          "\t\t\tif(!( Gadgets[ GD_%s ]->Flags & GFLG_DISABLED ))\n"
  956.                          "\t\t\t\tActivateGadget( Gadgets[ GD_%s ], Wnd, NULL );\n"
  957.                          "\t\t\tbreak;\n",
  958.                  ch, gad->g_Label, gad->g_Label );
  959.             } else {
  960.             FPrintf( Files->Std, "\n\t\tcase\t'%lc':\n"
  961.                          "\t\t\trunning = %sKeyPressed( Wnd, Gadgets, IE, Msg );\n"
  962.                          "\t\t\tbreak;\n",
  963.                  ch, gad->g_Label );
  964.  
  965.             FPrintf( Files->XDef, "extern BOOL %sKeyPressed( struct Window *, struct Gadget **, struct IE_Data *, struct IntuiMessage * );\n", gad->g_Label );
  966.  
  967.             if( IE->C_Prefs & GEN_TEMPLATE )
  968.                 FPrintf( Files->Temp, "\nBOOL %sKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )\n"
  969.                           "{\n"
  970.                           "\t/*  Routine when \"%s\"'s activation key is pressed  */\n"
  971.                           "\n"
  972.                           "\t/*  ...or return TRUE not to call the gadget function  */\n"
  973.                           "\treturn %sClicked( Wnd, Gadgets, IE );\n"
  974.                           "}\n",
  975.                      gad->g_Label, gad->g_Titolo, gad->g_Label );
  976.             }
  977.         }
  978.         }
  979.  
  980.         if( wnd->wi_IDCMP & IDCMP_VANILLAKEY )
  981.         FPrintf( Files->Std, "\n\t\tdefault:\n"
  982.                      "\t\t\trunning = %sVanillaKey( Code, Wnd, Gadgets, IE );\n"
  983.                      "\t\t\tbreak;\n",
  984.              wnd->wi_Label );
  985.  
  986.         FPuts( Files->Std, "\n\t}\n\treturn( running );\n}\n" );
  987.     }
  988.     }
  989. }
  990. ///
  991. /// WriteClickedPtrs
  992. void WriteClickedPtrs( struct GenFiles *Files, struct IE_Data *IE )
  993. {
  994.     struct WindowInfo  *wnd;
  995.     struct GadgetInfo  *gad;
  996.  
  997.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  998.     for( gad = wnd->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  999.         if(( gad->g_Kind != NUMBER_KIND ) && ( gad->g_Kind != TEXT_KIND )) {
  1000.  
  1001.         FPrintf( Files->XDef, "extern BOOL %sClicked( struct Window *, struct Gadget **, struct IE_Data *, struct IntuiMessage * );\n", gad->g_Label );
  1002.  
  1003.         if( IE->C_Prefs & GEN_TEMPLATE )
  1004.             FPrintf( Files->Temp, "\nBOOL %sClicked( struct Window *wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )\n"
  1005.                       "{\n"
  1006.                       "\t/*  Routine when \"%s\" is clicked  */\n"
  1007.                       "\treturn( TRUE );\n"
  1008.                       "}\n",
  1009.                  gad->g_Label, gad->g_Titolo );
  1010.         }
  1011.  
  1012.     }
  1013.  
  1014.     }
  1015. }
  1016. ///
  1017.  
  1018. // Data & Structures
  1019. /// WriteNewGadgets
  1020. void WriteNewGadgets( struct GenFiles *Files, struct IE_Data *IE )
  1021. {
  1022.     struct WindowInfo  *wnd;
  1023.     struct GadgetInfo  *gad;
  1024.     UBYTE               buffer[256], *or;
  1025.     UWORD               c, c2;
  1026.  
  1027.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  1028.     if( wnd->wi_NumGads - wnd->wi_NumBools ) {
  1029.  
  1030.         FPrintf( Files->XDef, "extern struct NewGadget\t\t%sNGad[];\n", wnd->wi_Label );
  1031.         FPrintf( Files->Std, "\nstruct NewGadget %sNGad[] = {\n\t", wnd->wi_Label );
  1032.  
  1033.         for( gad = wnd->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  1034.         if( gad->g_Kind < BOOLEAN ) {
  1035.  
  1036.             FPrintf( Files->Std, "%ld, %ld, %ld, %ld, ",
  1037.                  gad->g_Left - IE->ScreenData->XOffset,
  1038.                  gad->g_Top  - IE->ScreenData->YOffset,
  1039.                  gad->g_Width, gad->g_Height );
  1040.  
  1041.             if( gad->g_Titolo[0] ) {
  1042.             FPrintf( Files->Std, "\"%s\"", gad->g_Titolo );
  1043.             } else
  1044.             FPuts( Files->Std, Null );
  1045.  
  1046.             FPuts( Files->Std, ", " );
  1047.  
  1048.             if( gad->g_Font )
  1049.             FPrintf( Files->Std, "&%s", gad->g_Font->txa_Label );
  1050.             else
  1051.             FPuts( Files->Std, Null );
  1052.  
  1053.             FPrintf( Files->Std, ", GD_%s, ", gad->g_Label );
  1054.  
  1055.             if( gad->g_Flags ) {
  1056.  
  1057.             buffer[0] = '\0';
  1058.  
  1059.             if( gad->g_Flags & 32 ) {
  1060.                 strcpy( buffer, "NG_HIGHLABEL" );
  1061.                 or = "|";
  1062.             } else {
  1063.                 or = "";
  1064.             }
  1065.  
  1066.             c = gad->g_Flags & 0xFFDF;
  1067.             if( c ) {
  1068.                 strcat( buffer, or );
  1069.  
  1070.                 c2 = 0;
  1071.                 while(!( c & gadget_flags[ c2 ]))
  1072.                 c2 += 1;
  1073.  
  1074.                 strcat( buffer, GadFlags[ c2 ]);
  1075.             }
  1076.  
  1077.             FPuts( Files->Std, buffer );
  1078.             } else {
  1079.             FPuts( Files->Std, Null );
  1080.             }
  1081.  
  1082.             FPuts( Files->Std, ", NULL, " );
  1083.  
  1084.             if(( IE->C_Prefs & CLICKED ) && ( gad->g_Kind != TEXT_KIND ) && ( gad->g_Kind != NUMBER_KIND ))
  1085.             FPrintf( Files->Std, "(APTR)%sClicked", gad->g_Label );
  1086.             else
  1087.             FPuts( Files->Std, Null );
  1088.  
  1089.             FPuts( Files->Std, ",\n\t" );
  1090.         }
  1091.         }
  1092.  
  1093.         Flush( Files->Std );
  1094.         Seek( Files->Std, -3, OFFSET_CURRENT );
  1095.         FPuts( Files->Std, "\n};\n" );
  1096.  
  1097.     }
  1098.     }
  1099.  
  1100. }
  1101. ///
  1102. /// WriteGadgetTags
  1103. void WriteGadgetTags( struct GenFiles *Files, struct IE_Data *IE )
  1104. {
  1105.     struct WindowInfo  *wnd;
  1106.     struct GadgetInfo  *gad;
  1107.  
  1108.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  1109.     if( wnd->wi_NumGads - wnd->wi_NumBools ) {
  1110.  
  1111.         FPrintf( Files->XDef, "extern ULONG\t\t\t%sGTags[];\n", wnd->wi_Label );
  1112.         FPrintf( Files->Std, "\nULONG %sGTags[] = {\n\t", wnd->wi_Label );
  1113.  
  1114.         for( gad = wnd->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  1115.         if( gad->g_Kind < BOOLEAN ) {
  1116.  
  1117.             if( gad->g_Tags & 1 )
  1118.             FPuts( Files->Std, "(GT_Underscore), '_', " );
  1119.  
  1120.             switch( gad->g_Kind ) {
  1121.  
  1122.             case BUTTON_KIND:
  1123.                 if( gad->g_Tags & 2 )
  1124.                 FPuts( Files->Std, GADisabled );
  1125.                 if( gad->g_Tags & 4 )
  1126.                 FPuts( Files->Std, GAImmediate );
  1127.                 break;
  1128.  
  1129.             case CHECKBOX_KIND:
  1130.                 if( gad->g_Tags & 2 )
  1131.                 FPuts( Files->Std, GADisabled );
  1132.                 if( gad->g_Tags & 4 )
  1133.                 FPuts( Files->Std, "(GTCB_Checked), TRUE, " );
  1134.                 if( gad->g_Tags & 8 )
  1135.                 FPuts( Files->Std, "(GTCB_Scaled), TRUE, " );
  1136.                 break;
  1137.  
  1138.             case INTEGER_KIND:
  1139.                 if( ((struct IK)(gad->g_Data)).Num )
  1140.                 FPrintf( Files->Std, "(GTIN_Number), %ld, ", ((struct IK)(gad->g_Data)).Num );
  1141.                 if( ((struct IK)(gad->g_Data)).MaxC != 10 )
  1142.                 FPrintf( Files->Std, "(GTIN_MaxChars), %ld, ", ((struct IK)(gad->g_Data)).MaxC );
  1143.                 if( ((struct IK)(gad->g_Data)).Just )
  1144.                 FPrintf( Files->Std, "(STRINGA_Justification), %s, ", STRINGA_txts[ ((struct IK)(gad->g_Data)).Just ]);
  1145.                 if( gad->g_Tags & 2 )
  1146.                 FPuts( Files->Std, GADisabled );
  1147.                 if( gad->g_Tags & 4 )
  1148.                 FPuts( Files->Std, GAImmediate );
  1149.                 if(!( gad->g_Tags & 8 ))
  1150.                 FPuts( Files->Std, GATabCycle );
  1151.                 if( gad->g_Tags & 0x10 )
  1152.                 FPuts( Files->Std, STRINGAExitHelp );
  1153.                 if( gad->g_Tags & 0x20 )
  1154.                 FPuts( Files->Std, STRINGAReplaceMode );
  1155.                 break;
  1156.  
  1157.             case LISTVIEW_KIND:
  1158.                 if( gad->g_NumScelte )
  1159.                 FPrintf( Files->Std, "(GTLV_Labels), (ULONG)&%sList, ", gad->g_Label );
  1160.                 if( ((struct LK)(gad->g_Data)).Top )
  1161.                 FPrintf( Files->Std, "(GTLV_Top), %ld, ", ((struct LK)(gad->g_Data)).Top );
  1162.                 if( ((struct LK)(gad->g_Data)).Vis )
  1163.                 FPrintf( Files->Std, "(GTLV_MakeVisible), %ld, ", ((struct LK)(gad->g_Data)).Vis );
  1164.                 if( ((struct LK)(gad->g_Data)).ScW != 16 )
  1165.                 FPrintf( Files->Std, "(GTLV_ScrollWidth), %ld, ", ((struct LK)(gad->g_Data)).ScW );
  1166.                 if( ((struct LK)(gad->g_Data)).Sel )
  1167.                 FPrintf( Files->Std, "(GTLV_Selected), %ld, ", ((struct LK)(gad->g_Data)).Sel );
  1168.                 if( ((struct LK)(gad->g_Data)).Spc )
  1169.                 FPrintf( Files->Std, LAYOUTASpacing, ((struct LK)(gad->g_Data)).Spc );
  1170.                 if( ((struct LK)(gad->g_Data)).IH )
  1171.                 FPrintf( Files->Std, "(GTLV_ItemHeight), %ld, ", ((struct LK)(gad->g_Data)).IH );
  1172.                 if( ((struct LK)(gad->g_Data)).MaxP )
  1173.                 FPrintf( Files->Std, "(GTLV_MaxPen), %ld, ", ((struct LK)(gad->g_Data)).MaxP );
  1174.                 if( gad->g_Tags & 2 )
  1175.                 FPuts( Files->Std, GADisabled );
  1176.                 if( gad->g_Tags & 4 )
  1177.                 FPuts( Files->Std, "(GTLV_ReadOnly), TRUE, " );
  1178.                 if( gad->g_Tags & 8 )
  1179.                 FPuts( Files->Std, "(GTLV_ShowSelected), NULL, " );
  1180.                 break;
  1181.  
  1182.             case MX_KIND:
  1183.                 FPuts( Files->Std, "(GTMX_Labels), (ULONG)&" );
  1184.                 FPrintf( Files->Std, "%sLabels", gad->g_Label );
  1185.                 FPuts( Files->Std, "[0], " );
  1186.                 if( ((struct MK)(gad->g_Data)).Act )
  1187.                 FPrintf( Files->Std, "(GTMX_Active), %ld, ", ((struct MK)(gad->g_Data)).Act );
  1188.                 if( ((struct MK)(gad->g_Data)).Spc != 1 )
  1189.                 FPrintf( Files->Std, "(GTMX_Spacing), %ld, ", ((struct MK)(gad->g_Data)).Spc );
  1190.                 if( gad->g_Titolo[0] )
  1191.                 FPrintf( Files->Std, "(GTMX_TitlePlace), %s, ", GadFlags[ ((struct MK)(gad->g_Data)).TitPlc ]);
  1192.                 if( gad->g_Tags & 2 )
  1193.                 FPuts( Files->Std, GADisabled );
  1194.                 if( gad->g_Tags & 4 )
  1195.                 FPuts( Files->Std, "(GTMX_Scaled), TRUE, " );
  1196.                 break;
  1197.  
  1198.             case NUMBER_KIND:
  1199.                 if( ((struct NK)(gad->g_Data)).Num )
  1200.                 FPrintf( Files->Std, "(GTNM_Number), %ld, ", ((struct NK)(gad->g_Data)).Num );
  1201.                 if( ((struct NK)(gad->g_Data)).FPen != -1 )
  1202.                 FPrintf( Files->Std, "(GTNM_FrontPen), %ld, ", ((struct NK)(gad->g_Data)).FPen );
  1203.                 if( ((struct NK)(gad->g_Data)).BPen != -1 )
  1204.                 FPrintf( Files->Std, "(GTNM_BackPen), %ld, ", ((struct NK)(gad->g_Data)).BPen );
  1205.                 if( ((struct NK)(gad->g_Data)).Just )
  1206.                 FPrintf( Files->Std, "(GTNM_Justification), %s, ", GTJ_txts[ ((struct NK)(gad->g_Data)).Just ]);
  1207.                 if( ((struct NK)(gad->g_Data)).MNL != 10 )
  1208.                 FPrintf( Files->Std, "(GTNM_MaxNumberLen), %ld, ", ((struct NK)(gad->g_Data)).MNL );
  1209.                 if( strcmp( ((struct NK)(gad->g_Data)).Format, "%ld" )) {
  1210.                 FPuts( Files->Std, "(GTNM_Format), (ULONG)" );
  1211.                 FPrintf( Files->Std, "\"%s\", ", ((struct NK)(gad->g_Data)).Format );
  1212.                 }
  1213.                 if( gad->g_Tags & 2 )
  1214.                 FPuts( Files->Std, "(GTNM_Border), TRUE, " );
  1215.                 if( gad->g_Tags & 4 )
  1216.                 FPuts( Files->Std, "(GTNM_Clipped), TRUE, " );
  1217.                 break;
  1218.  
  1219.             case CYCLE_KIND:
  1220.                 FPuts( Files->Std, "(GTCY_Labels), (ULONG)&" );
  1221.                 FPrintf( Files->Std, "%sLabels", gad->g_Label );
  1222.                 FPuts( Files->Std, "[0], " );
  1223.                 if( ((struct CK)(gad->g_Data)).Act )
  1224.                 FPrintf( Files->Std, "(GTCY_Active), %ld, ", ((struct CK)(gad->g_Data)).Act );
  1225.                 if( gad->g_Tags & 2 )
  1226.                 FPuts( Files->Std, GADisabled );
  1227.                 break;
  1228.  
  1229.             case PALETTE_KIND:
  1230.                 if( ((struct PK)(gad->g_Data)).Depth != 1 )
  1231.                 FPrintf( Files->Std, "(GTPA_Depth), %ld, ", ((struct PK)(gad->g_Data)).Depth );
  1232.                 if( ((struct PK)(gad->g_Data)).Color != 1 )
  1233.                 FPrintf( Files->Std, "(GTPA_Color), %ld, ", ((struct PK)(gad->g_Data)).Color );
  1234.                 if( ((struct PK)(gad->g_Data)).ColOff )
  1235.                 FPrintf( Files->Std, "(GTPA_ColorOffset), %ld, ", ((struct PK)(gad->g_Data)).ColOff );
  1236.                 if( ((struct PK)(gad->g_Data)).IW )
  1237.                 FPrintf( Files->Std, "(GTPA_IndicatorWidth), %ld, ", ((struct PK)(gad->g_Data)).IW );
  1238.                 if( ((struct PK)(gad->g_Data)).IH )
  1239.                 FPrintf( Files->Std, "(GTPA_IndicatorHeight), %ld, ", ((struct PK)(gad->g_Data)).IH );
  1240.                 if(( ((struct PK)(gad->g_Data)).NumCol ) && ( ((struct PK)(gad->g_Data)).NumCol != 2 ))
  1241.                 FPrintf( Files->Std, "(GTPA_NumColors), %ld, ", ((struct PK)(gad->g_Data)).NumCol );
  1242.                 if( gad->g_Tags & 2 )
  1243.                 FPuts( Files->Std, GADisabled );
  1244.                 break;
  1245.  
  1246.             case SCROLLER_KIND:
  1247.                 if( ((struct SK)(gad->g_Data)).Top )
  1248.                 FPrintf( Files->Std, "(GTSC_Top), %ld, ", ((struct SK)(gad->g_Data)).Top );
  1249.                 if( ((struct SK)(gad->g_Data)).Tot )
  1250.                 FPrintf( Files->Std, "(GTSC_Total), %ld, ", ((struct SK)(gad->g_Data)).Tot );
  1251.                 if( ((struct SK)(gad->g_Data)).Vis != 2 )
  1252.                 FPrintf( Files->Std, "(GTSC_Visible), %ld, ", ((struct SK)(gad->g_Data)).Vis );
  1253.                 if( ((struct SK)(gad->g_Data)).Arr )
  1254.                 FPrintf( Files->Std, "(GTSC_Arrows), %ld, ", ((struct SK)(gad->g_Data)).Arr );
  1255.                 if( ((struct SK)(gad->g_Data)).Free )
  1256.                 FPuts( Files->Std, PGAFreedom );
  1257.                 if( gad->g_Tags & 2 )
  1258.                 FPuts( Files->Std, GADisabled );
  1259.                 if( gad->g_Tags & 2 )
  1260.                 FPuts( Files->Std, GARelVerify );
  1261.                 if( gad->g_Tags & 8 )
  1262.                 FPuts( Files->Std, GAImmediate );
  1263.                 break;
  1264.  
  1265.             case SLIDER_KIND:
  1266.                 if( ((struct SlK)(gad->g_Data)).Min )
  1267.                 FPrintf( Files->Std, "(GTSL_Min), %ld, ", ((struct SlK)(gad->g_Data)).Min );
  1268.                 if( ((struct SlK)(gad->g_Data)).Max != 15 )
  1269.                 FPrintf( Files->Std, "(GTSL_Max), %ld, ", ((struct SlK)(gad->g_Data)).Max );
  1270.                 if( ((struct SlK)(gad->g_Data)).Level )
  1271.                 FPrintf( Files->Std, "(GTSL_Level), %ld, ", ((struct SlK)(gad->g_Data)).Level );
  1272.                 if( ((struct SlK)(gad->g_Data)).MLL != 2 )
  1273.                 FPrintf( Files->Std, "(GTSL_MaxLevelLen), %ld, ", ((struct SlK)(gad->g_Data)).MLL );
  1274.                 FPrintf( Files->Std, "(GTSL_LevelPlace), %s, ", GadFlags[ ((struct SlK)(gad->g_Data)).LevPlc ]);
  1275.                 if( ((struct SlK)(gad->g_Data)).Just )
  1276.                 FPrintf( Files->Std, "(GTSL_Justification), %ld, ", GTJ_txts[ ((struct SlK)(gad->g_Data)).Just ]);
  1277.                 if( ((struct SlK)(gad->g_Data)).Free )
  1278.                 FPuts( Files->Std, PGAFreedom );
  1279.                 if( ((struct SlK)(gad->g_Data)).MPL )
  1280.                 FPrintf( Files->Std, "(GTSL_MaxPixelLen), %ld, ", ((struct SlK)(gad->g_Data)).MPL );
  1281.                 FPuts( Files->Std, "(GTSL_LevelFormat), (ULONG)" );
  1282.                 FPrintf( Files->Std, "\"%s\", ", ((struct SlK)(gad->g_Data)).Format );
  1283.                 if( gad->g_Tags & 2 )
  1284.                 FPuts( Files->Std, GADisabled );
  1285.                 if( gad->g_Tags & 2 )
  1286.                 FPuts( Files->Std, GARelVerify );
  1287.                 if( gad->g_Tags & 8 )
  1288.                 FPuts( Files->Std, GAImmediate );
  1289.                 break;
  1290.  
  1291.             case STRING_KIND:
  1292.                 if( ((struct StK)(gad->g_Data)).MaxC )
  1293.                 FPrintf( Files->Std, "(GTST_MaxChars), %ld, ", ((struct StK)(gad->g_Data)).MaxC );
  1294.                 if( ((struct StK)(gad->g_Data)).Just )
  1295.                 FPrintf( Files->Std, "(STRINGA_Justification), %s, ", STRINGA_txts[ ((struct StK)(gad->g_Data)).Just ]);
  1296.                 if ( *((UBYTE *)(gad->g_ExtraMem)) ) {
  1297.                 FPuts( Files->Std, "(GTST_String), (ULONG)" );
  1298.                 FPrintf( Files->Std, "\"%s\", ", gad->g_ExtraMem );
  1299.                 }
  1300.                 if( gad->g_Tags & 2 )
  1301.                 FPuts( Files->Std, GADisabled );
  1302.                 if( gad->g_Tags & 4 )
  1303.                 FPuts( Files->Std, GAImmediate );
  1304.                 if(!( gad->g_Tags & 8 ))
  1305.                 FPuts( Files->Std, GATabCycle );
  1306.                 if( gad->g_Tags & 0x10 )
  1307.                 FPuts( Files->Std, STRINGAExitHelp );
  1308.                 if( gad->g_Tags & 0x20 )
  1309.                 FPuts( Files->Std, STRINGAReplaceMode );
  1310.                 break;
  1311.  
  1312.             case TEXT_KIND:
  1313.                 if( ((struct TK)(gad->g_Data)).FPen != -1 )
  1314.                 FPrintf( Files->Std, "(GTTX_FrontPen), %ld, ", ((struct TK)(gad->g_Data)).FPen );
  1315.                 if( ((struct TK)(gad->g_Data)).BPen != -1 )
  1316.                 FPrintf( Files->Std, "(GTTX_BackPen), %ld, ", ((struct TK)(gad->g_Data)).BPen );
  1317.                 if( ((struct TK)(gad->g_Data)).Just )
  1318.                 FPrintf( Files->Std, "(GTTX_Justification), %s, ", GTJ_txts[ ((struct TK)(gad->g_Data)).Just ]);
  1319.                 if ( *((UBYTE *)(gad->g_ExtraMem)) ) {
  1320.                 FPuts( Files->Std, "(GTTX_Text), (ULONG)" );
  1321.                 FPrintf( Files->Std, "\"%s\", ", gad->g_ExtraMem );
  1322.                 }
  1323.                 if( gad->g_Tags & 2 )
  1324.                 FPuts( Files->Std, "(GTTX_CopyText), TRUE, " );
  1325.                 if( gad->g_Tags & 4 )
  1326.                 FPuts( Files->Std, "(GTTX_Border), TRUE, " );
  1327.                 if( gad->g_Tags & 8 )
  1328.                 FPuts( Files->Std, "(GTTX_Clipped), TRUE, " );
  1329.                 break;
  1330.             }
  1331.  
  1332.             FPuts( Files->Std, "(TAG_DONE),\n\t" );
  1333.         }
  1334.         }
  1335.  
  1336.         Flush( Files->Std );
  1337.         Seek( Files->Std, -3, OFFSET_CURRENT );
  1338.         FPuts( Files->Std, "\n};\n" );
  1339.  
  1340.     }
  1341.     }
  1342. }
  1343. ///
  1344. /// WriteITexts
  1345. void WriteITexts( struct GenFiles *Files, struct IE_Data *IE )
  1346. {
  1347.     struct WindowInfo  *wnd;
  1348.     struct ITextNode   *txt;
  1349.     struct TxtAttrNode *fnt;
  1350.     UWORD               x, y, next;
  1351.  
  1352.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  1353.     if( wnd->wi_NumTexts ) {
  1354.  
  1355.         FPrintf( Files->XDef, "extern struct IntuiText\t\t%sIText[];\n", wnd->wi_Label );
  1356.         FPrintf( Files->Std, "\nstruct IntuiText %sIText[] = {\n", wnd->wi_Label );
  1357.  
  1358.         next = 1;
  1359.  
  1360.         for( txt = wnd->wi_ITexts.mlh_Head; txt->itn_Node.ln_Succ; txt = txt->itn_Node.ln_Succ ) {
  1361.  
  1362.         FPrintf( Files->Std, "\t%ld, %ld, %ld, ",
  1363.              txt->itn_FrontPen, txt->itn_BackPen, txt->itn_DrawMode );
  1364.  
  1365.         x = txt->itn_LeftEdge - IE->ScreenData->XOffset;
  1366.         y = txt->itn_TopEdge - IE->ScreenData->YOffset;
  1367.  
  1368.         if( IE->SrcFlags & FONTSENSITIVE ) {
  1369.             x += ( IntuiTextLength(( struct IntuiText * )&txt->itn_FrontPen ) >> 1 );
  1370.             y += ( IE->ScreenData->Screen->RastPort.TxHeight >> 1 );
  1371.         }
  1372.  
  1373.         FPrintf( Files->Std, "%ld, %ld, ", x, y );
  1374.  
  1375.         if( fnt = txt->itn_ITextFont ) {
  1376.             (ULONG)fnt -= sizeof( struct Node );
  1377.             FPrintf( Files->Std, "&%s", fnt->txa_Label );
  1378.         } else {
  1379.             FPuts( Files->Std, Null );
  1380.         }
  1381.  
  1382.         FPuts( Files->Std, ", (UBYTE *)" );
  1383.  
  1384.         FPrintf( Files->Std, "\"%s\"", txt->itn_Text );
  1385.  
  1386.         if((!( IE->SrcFlags & FONTSENSITIVE )) && ( next != wnd->wi_NumTexts )) {
  1387.             FPrintf( Files->Std, ", &%sIText[%ld],\n", wnd->wi_Label, next );
  1388.             next += 1;
  1389.         } else {
  1390.             FPuts( Files->Std, ", NULL,\n" );
  1391.         }
  1392.         }
  1393.  
  1394.         Flush( Files->Std );
  1395.         Seek( Files->Std, -2, OFFSET_CURRENT );
  1396.         FPuts( Files->Std, "\n};\n" );
  1397.  
  1398.     }
  1399.     }
  1400. }
  1401. ///
  1402. /// WriteImgStruct
  1403. void WriteImgStruct( struct GenFiles *Files, struct IE_Data *IE )
  1404. {
  1405.     struct ImageNode   *img;
  1406.  
  1407.     for( img = IE->Img_List.mlh_Head; img->in_Node.ln_Succ; img = img->in_Node.ln_Succ ) {
  1408.  
  1409.     FPrintf( Files->XDef, "extern struct Image\t\t%sImg;\n", img->in_Label );
  1410.     FPrintf( Files->Std, "\nstruct Image %sImg = {\n", img->in_Label );
  1411.  
  1412.     VFPrintf( Files->Std, "\t%d, %d,\n\t%d, %d, %d,\n\t", &img->in_Left );
  1413.  
  1414.     if( img->in_Size )
  1415.         FPrintf( Files->Std, "%sImgData", img->in_Label );
  1416.     else
  1417.         FPuts( Files->Std, Null );
  1418.  
  1419.     FPrintf( Files->Std, ",\n\t%ld, %ld,\n\t0\n};\n",
  1420.          img->in_PlanePick, img->in_PlaneOnOff );
  1421.     }
  1422. }
  1423. ///
  1424. /// WriteImageStruct
  1425. void WriteImageStruct( struct GenFiles *Files, struct IE_Data *IE )
  1426. {
  1427.     struct WindowInfo  *wnd;
  1428.     struct WndImages   *img;
  1429.     UWORD               cnt;
  1430.  
  1431.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  1432.  
  1433.     cnt = 0;
  1434.  
  1435.     for( img = wnd->wi_Images.mlh_Head; img->wim_Next; img = img->wim_Next ) {
  1436.  
  1437.         FPrintf( Files->XDef, "extern struct Image\t\t%s_%ldImage;\n", wnd->wi_Label, cnt );
  1438.         FPrintf( Files->Std, "\nstruct Image %s_%ldImage = {\n", wnd->wi_Label, cnt );
  1439.  
  1440.         cnt += 1;
  1441.  
  1442.         FPrintf( Files->Std, "\t%ld, %ld,\n\t%ld, %ld, %ld,\n\t",
  1443.              img->wim_Left - IE->ScreenData->XOffset,
  1444.              img->wim_Top  - IE->ScreenData->YOffset,
  1445.              img->wim_Width, img->wim_Height, img->wim_Depth );
  1446.  
  1447.         if( img->wim_ImageNode->in_Size )
  1448.         FPrintf( Files->Std, "%sImgData", img->wim_ImageNode->in_Label );
  1449.         else
  1450.         FPuts( Files->Std, Null );
  1451.  
  1452.         FPrintf( Files->Std, ",\n\t%ld, %ld,\n\t",
  1453.              img->wim_PlanePick, img->wim_PlaneOnOff );
  1454.  
  1455.         if( cnt < wnd->wi_NumImages )
  1456.         FPrintf( Files->Std, "&%s_%ldImage", wnd->wi_Label, cnt );
  1457.         else
  1458.         FPuts( Files->Std, Null );
  1459.  
  1460.         FPuts( Files->Std, "\n};\n" );
  1461.     }
  1462.     }
  1463. }
  1464. ///
  1465. /// WriteWindowTags
  1466. void WriteWindowTags( struct GenFiles *Files, struct IE_Data *IE, struct WindowInfo *wnd )
  1467. {
  1468.     UWORD               w, h;
  1469.     ULONG               idcmp;
  1470.     static UBYTE WAIdcmp[] = "\n\t\t{ WA_IDCMP, ";
  1471.  
  1472.     FPrintf( Files->Std, "\n\tstruct TagItem WTags[] = {\n"
  1473.              "\t\t{ WA_Left, %ld },\n"
  1474.              "\t\t{ WA_Top, %ld },\n",
  1475.          wnd->wi_Left, wnd->wi_Top );
  1476.  
  1477.     if( IE->SrcFlags & FONTSENSITIVE ) {
  1478.     w = wnd->wi_Width - ( IE->ScreenData->XOffset + IE->ScreenData->Screen->WBorRight  );
  1479.     h = wnd->wi_Height - ( IE->ScreenData->YOffset + IE->ScreenData->Screen->WBorBottom );
  1480.     FPrintf( Files->Std, "\t\t{ WA_Width, ScaleX( FontX, %ld ) + IE->ScreenData->XOffset + IE->ScreenData->Screen->WBorRight },\n"
  1481.                  "\t\t{ WA_Height, ScaleY( FontY, %ld ) + IE->ScreenData->YOffset + IE->ScreenData->Screen->WBorBottom },\n",
  1482.          w, h );
  1483.     } else {
  1484.     FPrintf( Files->Std, "\t\t{ WA_Width, %ld + IE->ScreenData->XOffset },\n"
  1485.                  "\t\t{ WA_Height, %ld + IE->ScreenData->YOffset },\n",
  1486.          wnd->wi_Width - IE->ScreenData->XOffset,
  1487.          wnd->wi_Height - IE->ScreenData->YOffset );
  1488.     }
  1489.  
  1490.     VFPrintf( Files->Std, "\t\t{ WA_MinWidth, %d },\n"
  1491.               "\t\t{ WA_MaxWidth, %d },\n"
  1492.               "\t\t{ WA_MinHeight, %d },\n"
  1493.               "\t\t{ WA_MaxHeight, %d },",
  1494.           &wnd->wi_MinWidth );
  1495.  
  1496.     FPuts( Files->Std, "\n\t\t{ WA_PubScreen, IE->ScreenData->Screen }," );
  1497.  
  1498.     if( wnd->wi_Titolo[0] ) {
  1499.     FPuts( Files->Std, "\n\t\t{ WA_Title, (ULONG)" );
  1500.  
  1501.     FPrintf( Files->Std, "\"%s\"", wnd->wi_Titolo );
  1502.  
  1503.     FPuts( Files->Std, " }," );
  1504.     }
  1505.  
  1506.     if( wnd->wi_Flags ) {
  1507.     FPuts( Files->Std, "\n\t\t{ WA_Flags, " );
  1508.  
  1509.     for( w = 0; w < WFLAGS_NUM; w++ )
  1510.         if( wnd->wi_Flags & wflgs[ w ]) {
  1511.         FPuts( Files->Std, WndFlags[ w ]);
  1512.         FPutC( Files->Std, '|' );
  1513.         }
  1514.  
  1515.     Flush( Files->Std );
  1516.     Seek( Files->Std, -1, OFFSET_CURRENT );
  1517.     FPuts( Files->Std, " }," );
  1518.     }
  1519.  
  1520.     h = FALSE;
  1521.     for( w = 0; w < 13; w++ )
  1522.     if( wnd->wi_GadTypes[ w ])
  1523.         h = TRUE;
  1524.  
  1525.     if( h ) {
  1526.     FPuts( Files->Std, WAIdcmp );
  1527.  
  1528.     for( w = 0; w < 13; w++ ) {
  1529.         if( wnd->wi_GadTypes[ w ]) {
  1530.         FPuts( Files->Std, GadIDCMP[ w ]);
  1531.         FPutC( Files->Std, '|' );
  1532.         }
  1533.     }
  1534.  
  1535.     Flush( Files->Std );
  1536.     Seek( Files->Std, -1, OFFSET_CURRENT );
  1537.     FPutC( Files->Std, ' ' );
  1538.     }
  1539.  
  1540.     if( idcmp = wnd->wi_IDCMP ) {
  1541.  
  1542.     if(( IE->C_Prefs & KEY_HANDLER ) && ( wnd->wi_NumKeys ))
  1543.         idcmp |= IDCMP_VANILLAKEY;
  1544.  
  1545.     if( h ) {
  1546.         Flush( Files->Std );
  1547.         Seek( Files->Std, -1, OFFSET_CURRENT );
  1548.         FPutC( Files->Std, '|' );
  1549.     } else {
  1550.         FPuts( Files->Std, WAIdcmp );
  1551.     }
  1552.  
  1553.     for( w = 0; w < IDCMPS_NUM; w++ ) {
  1554.         if( idcmp & idcmps[ w ]) {
  1555.         FPuts( Files->Std, WndIDCMP[ w ]);
  1556.         FPutC( Files->Std, '|' );
  1557.         }
  1558.     }
  1559.  
  1560.     Flush( Files->Std );
  1561.     Seek( Files->Std, -1, OFFSET_CURRENT );
  1562.     FPutC( Files->Std, ' ' );
  1563.     }
  1564.  
  1565.     if(( h ) || ( wnd->wi_IDCMP ))
  1566.     FPuts( Files->Std, "}," );
  1567.  
  1568.     if( wnd->wi_TitoloSchermo[0] ) {
  1569.     FPuts( Files->Std, "\n\t\t{ WA_ScreenTitle, (ULONG)" );
  1570.  
  1571.     FPrintf( Files->Std, "\"%s\"", wnd->wi_TitoloSchermo );
  1572.  
  1573.     FPuts( Files->Std, " }," );
  1574.     }
  1575.  
  1576.     if( wnd->wi_Tags & W_MOUSEQUEUE )
  1577.     VFPrintf( Files->Std, "\n\t\t{ WA_MouseQueue, %d },", &wnd->wi_MouseQueue );
  1578.  
  1579.     if( wnd->wi_Tags & W_RPTQUEUE )
  1580.     VFPrintf( Files->Std, "\n\t\t{ WA_RptQueue, %d },", &wnd->wi_RptQueue );
  1581.  
  1582.     if(!( wnd->wi_Tags & W_AUTOADJUST ))
  1583.     FPuts( Files->Std, "\n\t\t{ WA_AutoAdjust, FALSE }," );
  1584.  
  1585.     if( wnd->wi_Tags & W_ZOOM )
  1586.     FPrintf( Files->Std, "\n\t\t{ WA_Zoom, %sZoom },", wnd->wi_Label );
  1587.  
  1588.     if( wnd->wi_flags1 & W_USA_INNER_W )
  1589.     VFPrintf( Files->Std, "\n\t\t{ WA_InnerWidth, %d },", &wnd->wi_InnerWidth );
  1590.  
  1591.     if( wnd->wi_flags1 & W_USA_INNER_H )
  1592.     VFPrintf( Files->Std, "\n\t\t{ WA_InnerHeight, %d },", &wnd->wi_InnerHeight );
  1593.  
  1594.     if( wnd->wi_NumGads )
  1595.     FPuts( Files->Std, "\n\t\t{ WA_Gadgets, *GList }," );
  1596.  
  1597.     if( wnd->wi_Tags & W_TABLETMESSAGE )
  1598.     FPuts( Files->Std, "\n\t\t{ WA_TabletMessages, TRUE }," );
  1599.  
  1600.     if( wnd->wi_Tags & W_NOTIFYDEPTH )
  1601.     FPuts( Files->Std, "\n\t\t{ WA_NotifyDepth, TRUE }," );
  1602.  
  1603.     FPuts( Files->Std, "\n\t\t{ TAG_DONE, NULL }\n\t};\n" );
  1604. }
  1605. ///
  1606.  
  1607.  
  1608. //  ***  Main Routines  ***
  1609. /// OpenFiles
  1610. struct GenFiles *OpenFiles( __A0 struct IE_Data *IE, __A1 UBYTE *BaseName )
  1611. {
  1612.     UBYTE               buffer[1024], buffer2[1024];
  1613.     UBYTE              *ptr, *ptr2, *ptr3;
  1614.     struct GenFiles    *Files;
  1615.  
  1616.     if(!( Files = AllocMem( sizeof( struct GenFiles ), MEMF_CLEAR )))
  1617.     return( NULL );
  1618.  
  1619.     ptr2 = FilePart( BaseName );
  1620.  
  1621.     ptr  = BaseName;
  1622.     ptr3 = buffer;
  1623.     while( ptr != ptr2 )
  1624.     *ptr3++ = *ptr++;
  1625.  
  1626.     *ptr3 = '\0';
  1627.  
  1628.     ptr = buffer2;
  1629.     while(( *ptr2 != '.' ) && ( *ptr2 ))
  1630.     *ptr++ = *ptr2++;
  1631.     *ptr = '\0';
  1632.  
  1633.     AddPart( buffer, buffer2, 1024 );
  1634.  
  1635.     strcpy( buffer2, buffer );
  1636.     strcat( buffer2, ".c" );
  1637.  
  1638.     if(!( Files->Std = Open( buffer2, MODE_NEWFILE )))
  1639.     return( NULL );
  1640.  
  1641.     strcpy( buffer2, buffer );
  1642.     strcat( buffer2, ".h" );
  1643.     strcpy( Files->XDefName, buffer2 );
  1644.  
  1645.     if(!( Files->XDef = Open( buffer2, MODE_NEWFILE )))
  1646.     goto error;
  1647.  
  1648.  
  1649.     if( IE->C_Prefs & GEN_TEMPLATE ) {
  1650.  
  1651.     strcpy( buffer2, buffer );
  1652.     strcat( buffer2, "_temp.c" );
  1653.  
  1654.     if(!( Files->Temp = Open( buffer2, MODE_NEWFILE )))
  1655.         goto error;
  1656.  
  1657.     }
  1658.  
  1659.     return( Files );
  1660.  
  1661.  
  1662. error:
  1663.  
  1664.     CloseFiles( Files );
  1665.  
  1666.     return( NULL );
  1667. }
  1668. ///
  1669. /// CloseFiles
  1670. void CloseFiles( __A0 struct GenFiles *Files )
  1671. {
  1672.     if( Files ) {
  1673.     if( Files->Std   )  Close( Files->Std   );
  1674.     if( Files->Temp  )  Close( Files->Temp  );
  1675.     if( Files->XDef  )  Close( Files->XDef  );
  1676.  
  1677.     FreeMem( Files, sizeof( struct GenFiles ));
  1678.     }
  1679. }
  1680. ///
  1681.  
  1682. /// WriteHeaders
  1683. BOOL WriteHeaders( __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  1684. {
  1685.  
  1686.     FPrintf( Files->Std,  Header, LibId, IE->User->Name, IE->User->Number );
  1687.     FPrintf( Files->XDef, Header, LibId, IE->User->Name, IE->User->Number );
  1688.  
  1689.     if( Files->Temp ) {
  1690.     FPrintf( Files->Temp, Header, LibId, IE->User->Name, IE->User->Number );
  1691.  
  1692.     FPuts( Files->Temp,
  1693.         "/*\n"
  1694.         "   In this file you'll find empty  template  routines\n"
  1695.         "   referenced in the GUI source.  You  can fill these\n"
  1696.         "   routines with your code or use them as a reference\n"
  1697.         "   to create your main program.\n"
  1698.         "*/\n\n"
  1699.         "#include <stdio.h>\n"
  1700.         "#include <exec/types.h>\n\n" );
  1701.     }
  1702.  
  1703.     FPuts( Files->Std, "#include <exec/types.h>\n"
  1704.                "#include <exec/nodes.h>\n"
  1705.                "#include <intuition/intuition.h>\n"
  1706.                "#include <intuition/gadgetclass.h>\n"
  1707.                "#include <libraries/gadtools.h>\n"
  1708.                "#include <clib/exec_protos.h>\n"
  1709.                "#include <clib/intuition_protos.h>\n"
  1710.                "#include <clib/gadtools_protos.h>\n"
  1711.                "#include <clib/graphics_protos.h>\n"
  1712.                "#ifdef PRAGMAS\n"
  1713.                "#include <pragmas/exec_pragmas.h>\n"
  1714.                "#include <pragmas/intuition_pragmas.h>\n"
  1715.                "#include <pragmas/graphics_pragmas.h>\n"
  1716.                "#include <pragmas/gadtools_pragmas.h>\n"
  1717.                "#endif\n"
  1718.                "#include <ctype.h>\n"
  1719.                "#include <string.h>\n\n"
  1720.                "#include \"DEV_IE:Include/IEditor.h\"\n\n" );
  1721.  
  1722.     FPuts( Files->XDef, "#ifndef EXEC_TYPES_H\n"
  1723.             "#include <exec/types.h>\n"
  1724.             "#endif\n"
  1725.             "#ifndef EXEC_NODES_H\n"
  1726.             "#include <exec/nodes.h>\n"
  1727.             "#endif\n"
  1728.             "#ifndef INTUITION_INTUITION_H\n"
  1729.             "#include <intuition/intuition.h>\n"
  1730.             "#endif\n"
  1731.             "#ifndef INTUITION_GADGETCLASS_H\n"
  1732.             "#include <intuition/gadgetclass.h>\n"
  1733.             "#endif\n"
  1734.             "#ifndef LIBRARIES_GADTOOLS_H\n"
  1735.             "#include <libraries/gadtools.h>\n"
  1736.             "#endif\n"
  1737.             "#ifndef CLIB_EXEC_PROTOS_H\n"
  1738.             "#include <clib/exec_protos.h>\n"
  1739.             "#endif\n"
  1740.             "#ifndef CLIB_INTUITION_PROTOS_H\n"
  1741.             "#include <clib/intuition_protos.h>\n"
  1742.             "#endif\n"
  1743.             "#ifndef CLIB_GADTOOLS_PROTOS_H\n"
  1744.             "#include <clib/gadtools_protos.h>\n"
  1745.             "#endif\n"
  1746.             "#ifndef CLIB_GRAPHICS_PROTOS_H\n"
  1747.             "#include <clib/graphics_protos.h>\n"
  1748.             "#endif\n"
  1749.             "#ifndef CTYPE_H\n"
  1750.             "#include <ctype.h>\n"
  1751.             "#endif\n"
  1752.             "#ifndef STRING_H\n"
  1753.             "#include <string.h>\n"
  1754.             "#endif\n\n" );
  1755.  
  1756.  
  1757.  
  1758.     FPrintf( Files->Std, "#include \"%s\"\n\n", FilePart( Files->XDefName ));
  1759.  
  1760.  
  1761.     FPuts( Files->XDef, "#define GetString( g )\t((( struct StringInfo * )g->SpecialInfo )->Buffer  )\n"
  1762.             "#define GetNumber( g )\t((( struct StringInfo * )g->SpecialInfo )->LongInt )\n\n"
  1763.             "#define WT_LEFT\t\t\t\t0\n"
  1764.             "#define WT_TOP\t\t\t\t1\n"
  1765.             "#define WT_WIDTH\t\t\t2\n"
  1766.             "#define WT_HEIGHT\t\t\t3\n\n" );
  1767.  
  1768.  
  1769.     struct WindowInfo  *wnd;
  1770.     struct GadgetInfo  *gad;
  1771.     int                 cnt;
  1772.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  1773.     if( wnd->wi_NumGads - wnd->wi_NumBools ) {
  1774.         cnt = 0;
  1775.         for( gad = wnd->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  1776.         FPrintf( Files->XDef, "#define GD_%s\t\t\t\t\t%ld\n", gad->g_Label, cnt );
  1777.         cnt += 1;
  1778.         }
  1779.         FPutC( Files->XDef, 10 );
  1780.     }
  1781.     }
  1782.  
  1783.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  1784.     cnt = wnd->wi_NumGads - wnd->wi_NumBools;
  1785.     if( cnt )
  1786.         FPrintf( Files->XDef, "#define %s_CNT %ld\n", wnd->wi_Label, cnt );
  1787.     }
  1788.  
  1789.     FPutC( Files->XDef, 10 );
  1790.  
  1791.     return( TRUE );
  1792. }
  1793. ///
  1794. /// WriteVars
  1795. BOOL WriteVars( __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  1796. {
  1797.     FPuts( Files->XDef, "extern struct IntuitionBase\t*IntuitionBase;\n"
  1798.             "extern struct Library\t\t*GadToolsBase;\n" );
  1799.  
  1800.     return( TRUE );
  1801. }
  1802. ///
  1803. /// WriteData
  1804. BOOL WriteData( __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  1805. {
  1806.     struct WindowInfo  *wnd;
  1807.     struct GadgetInfo  *gad;
  1808.  
  1809.     // Gadget Labels
  1810.  
  1811.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  1812.  
  1813.     for( gad = wnd->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  1814.  
  1815.         switch( gad->g_Kind ) {
  1816.  
  1817.         case LISTVIEW_KIND:
  1818.             WriteList( Files, &gad->g_Scelte, gad->g_Label, gad->g_NumScelte, IE );
  1819.             break;
  1820.  
  1821.         case MX_KIND:
  1822.         case CYCLE_KIND:
  1823.  
  1824.             struct GadgetScelta *gs;
  1825.  
  1826.             FPrintf( Files->XDef, "extern UBYTE\t\t\t*%sLabels[];\n", gad->g_Label );
  1827.             FPrintf( Files->Std,  "\nUBYTE *%sLabels[] = {\n\t", gad->g_Label );
  1828.  
  1829.             for( gs = gad->g_Scelte.mlh_Head; gs->gs_Node.ln_Succ; gs = gs->gs_Node.ln_Succ )
  1830.             FPrintf( Files->Std, "(UBYTE *)\"%s\",\n\t", gs->gs_Testo );
  1831.  
  1832.             FPuts( Files->Std, "NULL\n};\n" );
  1833.             break;
  1834.         }
  1835.  
  1836.     }
  1837.     }
  1838.  
  1839.     // Gadget Types
  1840.  
  1841.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  1842.     if( wnd->wi_NumGads - wnd->wi_NumBools ) {
  1843.  
  1844.         FPrintf( Files->XDef, "extern UWORD\t\t\t%sGTypes[];\n", wnd->wi_Label );
  1845.         FPrintf( Files->Std, "\nUWORD %sGTypes[] = {\n\t", wnd->wi_Label );
  1846.  
  1847.         for( gad = wnd->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  1848.         if( gad->g_Kind < BOOLEAN ) {
  1849.             FPuts( Files->Std, GadKinds[ gad->g_Kind - 1 ]);
  1850.             FPuts( Files->Std, ",\n\t" );
  1851.         }
  1852.         }
  1853.  
  1854.         FPuts( Files->Std, "NULL };\n" );
  1855.  
  1856.     }
  1857.     }
  1858.  
  1859.     // Fonts
  1860.  
  1861.     struct TxtAttrNode *fnt;
  1862.     for( fnt = IE->FntLst.mlh_Head; fnt->txa_Next; fnt = fnt->txa_Next ) {
  1863.     FPrintf( Files->XDef, "extern struct TextAttr\t\t%s;\n", fnt->txa_Label );
  1864.     FPrintf( Files->Std, "\nstruct TextAttr %s = {\n"
  1865.                  "\t(STRPTR)\"%s\", %ld, 0x%lx, 0x%lx };\n",
  1866.          fnt->txa_Label, fnt->txa_FontName, fnt->txa_Size,
  1867.          fnt->txa_Style, fnt->txa_Flags );
  1868.     }
  1869.  
  1870.  
  1871.     // NewGadget structures
  1872.     WriteNewGadgets( Files, IE );
  1873.  
  1874.     // Gadget Tags
  1875.     WriteGadgetTags( Files, IE );
  1876.  
  1877.     // IntuiTexts
  1878.     WriteITexts( Files, IE );
  1879.  
  1880.     // Images (used by the GUI)
  1881.     WriteImgStruct( Files, IE );
  1882.  
  1883.     // Images (in windows)
  1884.     WriteImageStruct( Files, IE );
  1885.  
  1886.     // Windows' Zoom
  1887.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  1888.     if( wnd->wi_Tags & W_ZOOM ) {
  1889.         FPrintf( Files->XDef, "extern UWORD\t\t\t%sZoom[];\n", wnd->wi_Label );
  1890.         FPrintf( Files->Std, "\nUWORD %sZoom[] = { ", wnd->wi_Label );
  1891.         VFPrintf( Files->Std, "%d, %d, %d, %d };\n", &wnd->wi_ZLeft );
  1892.     }
  1893.     }
  1894.  
  1895.     return( TRUE );
  1896. }
  1897. ///
  1898. /// WriteChipData
  1899. BOOL WriteChipData( __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  1900. {
  1901.     struct ImageNode   *img;
  1902.     UWORD               words, num, *ptr;
  1903.  
  1904.     for( img = IE->Img_List.mlh_Head; img->in_Node.ln_Succ; img = img->in_Node.ln_Succ ) {
  1905.     if( img->in_Size ) {
  1906.  
  1907.         words = img->in_Size >> 1;
  1908.  
  1909.         FPrintf( Files->Std, "\n%s %sImgData[%ld] = {\n\t",
  1910.              IE->ChipString, img->in_Label, words );
  1911.  
  1912.         FPrintf( Files->XDef, "extern %s %sImgData[%ld];\n",
  1913.              IE->ChipString, img->in_Label, words );
  1914.  
  1915.         ptr = img->in_Data;
  1916.  
  1917.         num = 8;
  1918.         do {
  1919.  
  1920.         FPrintf( Files->Std, "0x%04lx", *ptr++ );
  1921.  
  1922.         num   -= 1;
  1923.         words -= 1;
  1924.  
  1925.         if( words ) {
  1926.  
  1927.             FPutC( Files->Std, ',' );
  1928.  
  1929.             if(!( num )) {
  1930.             FPuts( Files->Std, "\n\t" );
  1931.             num = 8;
  1932.             }
  1933.         }
  1934.  
  1935.         } while( words );
  1936.  
  1937.         FPuts( Files->Std, "\n};\n" );
  1938.  
  1939.     }
  1940.     }
  1941.  
  1942.     return( TRUE );
  1943. }
  1944. ///
  1945. /// WriteCode
  1946. BOOL WriteCode( __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  1947. {
  1948.  
  1949.     WriteSetupScr( Files, IE );
  1950.  
  1951.     WriteOpenWnd( Files, IE );
  1952.  
  1953.     WriteRender( Files, IE );
  1954.  
  1955.     if( IE->C_Prefs & IDCMP_HANDLER )
  1956.     WriteIDCMPHandler( Files, IE );
  1957.  
  1958.     if( IE->C_Prefs & KEY_HANDLER )
  1959.     WriteKeyHandler( Files, IE );
  1960.  
  1961.     FPuts( Files->XDef, "\nextern void CloseWnd( struct Window **Wnd, struct Gadget **GList );\n" );
  1962.  
  1963.     if( IE->C_Prefs & CLICKED )
  1964.     WriteClickedPtrs( Files, IE );
  1965.  
  1966.     return( TRUE );
  1967. }
  1968. ///
  1969. /// WriteStrings
  1970. BOOL WriteStrings( __A0 struct GenFiles *Files, __A1 struct IE_Data *IE )
  1971. {
  1972.     return( TRUE );
  1973. }
  1974. ///
  1975.  
  1976. /// Config
  1977. void Config( __A0 struct IE_Data *IE )
  1978. {
  1979.     struct Window  *Wnd = NULL;
  1980.     struct Gadget  *GList = NULL, *Gadgets[ Conf_CNT ];
  1981.     UBYTE           Back;
  1982.     BOOL            ret;
  1983.  
  1984.     if( OpenConfWindow( &Wnd, &GList, &Gadgets[0], IE )) {
  1985.  
  1986.     (*IE->Functions->Status)( "Cannot open my window!", TRUE, 0 );
  1987.  
  1988.     } else {
  1989.  
  1990.     Back = IE->C_Prefs;
  1991.  
  1992.     IE->C_Prefs = ~IE->C_Prefs;
  1993.     TemplateKeyPressed( Wnd, Gadgets, IE );
  1994.     ClickKeyPressed( Wnd, Gadgets, IE );
  1995.     HandlerKeyPressed( Wnd, Gadgets, IE );
  1996.     KeyHandlerKeyPressed( Wnd, Gadgets, IE );
  1997.     ToLowerKeyPressed( Wnd, Gadgets, IE );
  1998.  
  1999.     IE->C_Prefs = Back;
  2000.  
  2001.     GT_SetGadgetAttrs( Gadgets[ GD_Chip ], Wnd, NULL,
  2002.                GTST_String, IE->ChipString, TAG_END );
  2003.  
  2004.     do {
  2005.         WaitPort( Wnd->UserPort );
  2006.         ret = HandleConfIDCMP( Wnd, &Gadgets[0], IE );
  2007.     } while ( ret == 0 );
  2008.  
  2009.     if( ret > 0 ) {
  2010.         IE->C_Prefs = Back;
  2011.     } else {
  2012.         strcpy( IE->ChipString, GetString( Gadgets[ GD_Chip ] ));
  2013.     }
  2014.  
  2015.     }
  2016.  
  2017.     CloseWnd( &Wnd, &GList );
  2018. }
  2019.  
  2020.  
  2021. BOOL ClickKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2022. {
  2023.     /*  Routine when "Clicked _Ptr  "'s activation key is pressed  */
  2024.  
  2025.     CheckedTag[1] = ( IE->C_Prefs & CLICKED ) ? FALSE : TRUE;
  2026.     GT_SetGadgetAttrsA( Gadgets[ GD_Click ], Wnd,
  2027.             NULL, (struct TagItem *)CheckedTag );
  2028.  
  2029.     /*  ...or return TRUE not to call the gadget function  */
  2030.     return ClickClicked( Wnd, Gadgets, IE );
  2031. }
  2032.  
  2033. BOOL OkKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2034. {
  2035.     /*  Routine when "_Ok"'s activation key is pressed  */
  2036.  
  2037.     /*  ...or return TRUE not to call the gadget function  */
  2038.     return OkClicked( Wnd, Gadgets, IE );
  2039. }
  2040.  
  2041. BOOL CancKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2042. {
  2043.     /*  Routine when "_Cancel"'s activation key is pressed  */
  2044.  
  2045.     /*  ...or return TRUE not to call the gadget function  */
  2046.     return CancClicked( Wnd, Gadgets, IE );
  2047. }
  2048.  
  2049. BOOL HandlerKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2050. {
  2051.     /*  Routine when "IDCMP _Handler"'s activation key is pressed  */
  2052.  
  2053.     CheckedTag[1] = ( IE->C_Prefs & IDCMP_HANDLER ) ? FALSE : TRUE;
  2054.     GT_SetGadgetAttrsA( Gadgets[ GD_Handler ], Wnd,
  2055.             NULL, (struct TagItem *)CheckedTag );
  2056.  
  2057.     /*  ...or return TRUE not to call the gadget function  */
  2058.     return HandlerClicked( Wnd, Gadgets, IE );
  2059. }
  2060.  
  2061. BOOL KeyHandlerKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2062. {
  2063.     /*  Routine when "_Key Handler  "'s activation key is pressed  */
  2064.  
  2065.     CheckedTag[1] = ( IE->C_Prefs & KEY_HANDLER ) ? FALSE : TRUE;
  2066.     GT_SetGadgetAttrsA( Gadgets[ GD_KeyHandler ], Wnd,
  2067.             NULL, (struct TagItem *)CheckedTag );
  2068.  
  2069.     /*  ...or return TRUE not to call the gadget function  */
  2070.     return KeyHandlerClicked( Wnd, Gadgets, IE );
  2071. }
  2072.  
  2073. BOOL TemplateKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2074. {
  2075.     /*  Routine when "_Template     "'s activation key is pressed  */
  2076.     CheckedTag[1] = ( IE->C_Prefs & GEN_TEMPLATE ) ? FALSE : TRUE;
  2077.     GT_SetGadgetAttrsA( Gadgets[ GD_Template ], Wnd,
  2078.             NULL, (struct TagItem *)CheckedTag );
  2079.  
  2080.     /*  ...or return TRUE not to call the gadget function  */
  2081.     return TemplateClicked( Wnd, Gadgets, IE );
  2082. }
  2083.  
  2084. BOOL ToLowerKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2085. {
  2086.     /*  Routine when "To Lo_wer     "'s activation key is pressed  */
  2087.     CheckedTag[1] = ( IE->C_Prefs & TO_LOWER ) ? FALSE : TRUE;
  2088.     GT_SetGadgetAttrsA( Gadgets[ GD_ToLower ], Wnd,
  2089.             NULL, (struct TagItem *)CheckedTag );
  2090.  
  2091.     /*  ...or return TRUE not to call the gadget function  */
  2092.     return ToLowerClicked( Wnd, Gadgets, IE );
  2093. }
  2094.  
  2095. BOOL ClickClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2096. {
  2097.     /*  Routine when "Clicked _Ptr  " is clicked  */
  2098.  
  2099.     IE->C_Prefs ^= CLICKED;
  2100.  
  2101.     return( 0 );
  2102. }
  2103.  
  2104. BOOL OkClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2105. {
  2106.     /*  Routine when "_Ok" is clicked  */
  2107.     return( -1 );
  2108. }
  2109.  
  2110. BOOL CancClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2111. {
  2112.     /*  Routine when "_Cancel" is clicked  */
  2113.     return( 1 );
  2114. }
  2115.  
  2116. BOOL HandlerClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2117. {
  2118.     /*  Routine when "IDCMP _Handler" is clicked  */
  2119.  
  2120.     IE->C_Prefs ^= IDCMP_HANDLER;
  2121.  
  2122.     if( IE->C_Prefs & IDCMP_HANDLER ) {
  2123.  
  2124.         IE->C_Prefs &= ~( CLICKED | INTUIMSG );
  2125.  
  2126.         ClickKeyPressed( Wnd, Gadgets, IE );
  2127.     }
  2128.  
  2129.     return( 0 );
  2130. }
  2131.  
  2132. BOOL KeyHandlerClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2133. {
  2134.     /*  Routine when "_Key Handler  " is clicked  */
  2135.  
  2136.     IE->C_Prefs ^= KEY_HANDLER;
  2137.  
  2138.     if( IE->C_Prefs & KEY_HANDLER ) {
  2139.  
  2140.         IE->C_Prefs &= ~( CLICKED | INTUIMSG );
  2141.  
  2142.         ClickKeyPressed( Wnd, Gadgets, IE );
  2143.     }
  2144.  
  2145.     return( 0 );
  2146. }
  2147.  
  2148. BOOL TemplateClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2149. {
  2150.     /*  Routine when "_Template     " is clicked  */
  2151.  
  2152.     IE->C_Prefs ^= GEN_TEMPLATE;
  2153.  
  2154.     return( 0 );
  2155. }
  2156.  
  2157. BOOL ToLowerClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2158. {
  2159.     /*  Routine when "To Lo_wer     " is clicked  */
  2160.  
  2161.     IE->C_Prefs ^= TO_LOWER;
  2162.  
  2163.     return( 0 );
  2164. }
  2165.  
  2166. BOOL ChipClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE )
  2167. {
  2168.     /*  Routine when "_UWORD chip:" is clicked  */
  2169.     return( 0 );
  2170. }                
  2171. ///
  2172.